Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content of custom fields of type URL (Generate link) is not displayed in listviews #9232

Open
gody01 opened this issue Jul 15, 2021 · 4 comments
Labels
Area: Module Issues & PRs related to modules that do not have specific label PR:Type:Enhancement Pull requests that provide more functionality. Associated Issues are called suggestions Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type: Bug Bugs within the core SuiteCRM codebase

Comments

@gody01
Copy link
Contributor

gody01 commented Jul 15, 2021

If one create custom field in studio of type URL and assign it in listview, no content is showed in the corresponding column in listview.

Issue

In studio I created custom field of type URL in Accounts module.
Then I assigned it to DetailView and ListView.
When I go to DetailView I see content of new field.
When I go to ListView there is no content in detail view.

Expected Behavior

If field of Type URL is assigned to ListView, conten should be displayed

Actual Behavior

There is no content in column on the ListView

Possible Fix

It is acctualy problem, that in include/ListView/ListViewData.php main_query returns empty string, since URL field is generated according to vardefs.

So one solution/workaround is to create logic_hook to populate correct data (it turn's out it is very simple):

<?php

     class AlterCustomURL_fieldname
     {
         function AlterURL($bean, $event, $arguments)
         {
             $bean->fieldname_c = $bean->field_name_map['fieldname_c']['default'] ;
         }
     }

?>

Template than already replaces what should be replaced.

Steps to Reproduce

  1. Create field in studio of type URL
  2. Add Field to ListView (DetailView, ...)
  3. Populate relevant data (if it is generated URL from existing {id} for example nothing needs to be done.
  4. Go to ListView

Context

I tried to make customization and relied to documentation, that I can put cutom fields to ListView

Apart from tme spent searching and debuging for cause, workaroujnd turns out to be prety simple.
So perhaps some documentation/example would be enough.

But it would be better if procesing of vardefs definiton and above code would be introduced somewhere in include/ListView/ListViewData.php so that this would work without need for logic_hook for each new custom field of type URL.

Your Environment

  • SuiteCRM Version used: 7.11.20
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Independent of browser
  • Environment name and version (e.g. MySQL, PHP 7): Independent of Mysql/PHP
  • Operating System and version (e.g Ubuntu 16.04): tested on OpenSuSE Leap & Tumbletweed and CentOS 7 & 8.
gody01 added a commit to gody01/SuiteCRM that referenced this issue Jul 15, 2021
…ields of type URL (Generate link) is not displayed in listviews salesagility#9232

include dependend fields for url field in $filter_fields.

public function setupFilterFields

 Changes to be committed:
	modified:   ListViewDisplay.php
gody01 added a commit to gody01/SuiteCRM that referenced this issue Jul 15, 2021
…ields of type URL (Generate link) is not displayed in listviews salesagility#9232

For generated 'url' field type, export valaue of default as value to display.

On branch 9232_listview_display_url_content_type
Cherry-pick currently in progress.

Changes to be committed:
	modified:   SugarBean.php
@johnM2401 johnM2401 added Area: Module Issues & PRs related to modules that do not have specific label Status:Requires Updates Issues & PRs which requires input or update from the author labels Jul 22, 2021
@johnM2401
Copy link
Contributor

johnM2401 commented Jul 22, 2021

Hey there,

I'm not able to replicate this currently, i'm afraid.

It appears to render as expected on Listview:
image

Here are the steps I'd taken, please let me know if anything was missed:

  • Create the custom URL field
    image

Created with the above parameters

  • Added the field to the Edit/Detail/Listviews

  • Create a new Account record

  • The URL field is generated as the ID, as expected:
    image
    image


I did notice that, if I have not yet edited an existing record aftering adding the field, the content of the custom URL field is blank.
However, I don't believe the CRM would automatically populate this field in the DB for all records, upon the creation of the Field.
(Though I'm not 100% sure how the URL/Generate functionality works)

Please correct me if I'm wrong, but it sounds as though the fields may not be populated, as the records have yet to be saved after the addition of this new field.

Do you see the URL content if you edit/create a record after adding the Custom URL field?

@gody01
Copy link
Contributor Author

gody01 commented Jul 22, 2021

  1. Instead of {id}, please try use some custom field for Generate.
    Like create custom field remote_id_c
    And then use that in URL link.

  2. If You put generated URL field in DetailView, it will display value regardles if it is entered/saved before. It will take default value and display it (URL field type is now changed to link type and then displayes thru Field/Link template).
    And in template it has replacement with default defintion.

in pull request #9234:

  • removed replacement of url type to link type in include/SugarFields/SugarFieldHandler.php
  • renamed include/SugarFields/Fields/URL folder to include/SugarFields/Fields/Url - so that SuiteCRM picks up correct templates for url field type.
  • in data/SugarBean.php added lines to return value of default definition for url field
  • in include/ListView/ListViewDisplay.php added logic which adds fields from url default value (inside {}) to filter to retrieve correct non default values (this fixes missing custom fields in listViewDisplay of url type fields).
  • changed include/SugarFields/Fields/Url/ListView.tpl do that generated url field is displayed also for records, which don't have saved value in custom_c field in db.

If url field is generated, there is no point that value is retrieved from db. For example (real word example):

We put in URL type field link to external app, generated with external_app_id_c like:

https://externalapp.example.com/index.php?id={external_app_id_c}

Now fixed part of URL (https://externalapp.example.com) is changed to https://externalapp.newcomapny.com. if we get value from DB, all existing records will have old value. But with changes in pull request, all existing record will point to new URL, when we change default value in URL field definition ...

Let's say its feature and fix for handling generating URL generated field with custom_fields in {}

@johnM2401 johnM2401 added PR:Type:Enhancement Pull requests that provide more functionality. Associated Issues are called suggestions Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type: Bug Bugs within the core SuiteCRM codebase and removed Status:Requires Updates Issues & PRs which requires input or update from the author labels Jul 23, 2021
@johnM2401
Copy link
Contributor

Hey,

Thanks for the additional info!
I'm able to replicate it with Custom fields, so I have marked this Bug appropriately

@gody01
Copy link
Contributor Author

gody01 commented Jul 27, 2021

I created separte pull request with fix only for fetching used custom fields (bug fix):
Isolated change to fetch required custom fields, generated URL type d… #9241

Still think, that pull request #9234 is more complete solution, so that it behaviour is sam on DetailView as in ListView (displayed data changed from default definition regardles of DB saved field - it is Generated field after all).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Module Issues & PRs related to modules that do not have specific label PR:Type:Enhancement Pull requests that provide more functionality. Associated Issues are called suggestions Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type: Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

No branches or pull requests

2 participants