Description
When searching for assets in facilities, field service templates do not work.
Steps to Reproduce
-
Install Facilities Management with demo data.
For more information, see the product documentation topic Facilities Service Management.
-
Open any Facilities Request Template.
-
Click Edit Fields and add the Asset field to the request.
-
Attempt to search for an asset starting with the string "FAC".
Note that the search does not work.
Workaround
-
Edit the _readNewTemplateFields function SMTemplateHelper Script Include. Remove the if (fieldType == 'reference) if block and replace it with the following code.
if (fieldType == 'reference') { var reference = gr.getElement(tempFields.field).getED().getReference(); var name = new GlideRecord(reference); name.get(tempFields.getValue('value')); var qualifier = ''; if(appName == 'hr' && newField['name'] == 'request_category') qualifier = 'active=true'; else { var refQual = gr.getElement(tempFields.field).getED().getReferenceQualifier(); if (refQual && !refQual.startsWith("javascript:")) qualifier = refQual; } newField['ed'] = { 'displayValue' : name.getDisplayValue(), 'qualifier' : qualifier, 'reference' : reference, 'value' : tempFields.getValue('value') }; newField['qualifier'] = qualifier + ''; newField['reference'] = reference + ''; var ed = gr.getElement(tempFields.field).getED(); if (ed.hasAttribute('ref_ac_columns_search') && ed.getAttribute('ref_ac_columns_search') == 'true' && ed.hasAttribute('ref_ac_columns') && (ed.getAttribute('ref_ac_columns') && true)) { newField.ed.attributes = 'ref_ac_columns_search=true,ref_ac_columns=' + ed.getAttribute('ref_ac_columns'); } else if (ed.hasAttribute('ref_ac_order_by') && (ed.getAttribute('ref_ac_order_by') && true)) { newField.ed.attributes = 'ref_ac_order_by=' + ed.getAttribute('ref_ac_order_by'); } else newField.ed.searchField = name.getDisplayName(); }
-
Open the template to which you'd like to add the asset field. Add the asset field and save the template.
-
Reload the page and click Edit fields.
You should now be able to search the asset field.
Related Problem: PRB1291638