Show fields in reference popup built with custom renderer

  • 1
  • Problem
  • Updated 2 years ago
  • Solved
I have a custom field renderer on a reference field like this:

field.options.template = '{{Patient_Case__r.Patient__r.Name}} exam on {{Timeless_Date__c}}';
skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
My search popup has only the Id field.

If I add searchFields to the renderer, like so:
field.options.searchFields = [
        {id: 'Id'},
        {id: 'Timeless_Date__c'},
        {id: 'Patient_Case__r.Patient__r.Name'}
    ];

Nothing changes.

If I add returnFields like so:
    field.options.returnFields = [
        {id: 'Id'},
        {id: 'Timeless_Date__c'},
        {id: 'Patient_Case__r.Patient__r.Name'}
    ];

Then my search popup doesn't show any fields at all.

Help?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Emily Davis

Emily Davis, Employee

  • 3,502 Points 3k badge 2x thumb
Hey Matt,
For your reference fields, I think you need an additional property showInSearchDialog. Set this to true for each field you want to show in the search popup. So your reference fields code would change to something like:

field.options.returnFields = [
        {id: 'Id', showInSearchDialog: false},
        {id: 'Timeless_Date__c', showInSearchDialog: true}, {id: 'Patient_Case__r.Patient__r.Name', showInSearchDialog: true}
    ];
When you say "nothing changes" with the search fields, do you mean things are working as expected, or no? You MIGHT have to specify an additional property for those as well: searchOperator. So this would change your search fields to:

field.options.searchFields = [
        {id: 'Id', searchOperator: 'contains'},
        {id: 'Timeless_Date__c', searchOperator: 'contains'},
        {id: 'Patient_Case__r.Patient__r.Name', searchOperator: 'contains'}
    ];
Let me know if that helps.
Emily
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
The `showInSearchDialog` parameter did the trick. Thanks!

Now let's document that somewhere, shall we? ;)
Photo of Emily Davis

Emily Davis, Employee

  • 3,502 Points 3k badge 2x thumb
Matt,
Agreed! I'll mention it to our docs team. The way I figured out the extra properties was by adding some search fields in the builder and running a custom renderer on the field that simply console.log's the field to see the options. Not as ideal as documentation, though...
Emily
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
nice trick! thanks.