ORDERBY not working with JavaScript Reference Qualifier in Record Producer

kiran115
Tera Contributor

Description:
I have a Record Producer with two fields — Services and Solutions.
Both Services and Solutions are Lookup Select Box variables.
The Solutions field is dependent on the Services field, and I’ve mapped this dependency through a custom field called u_dependent_field on the referenced table.

  • Scenario 1: When I use a static reference qualifier (without JavaScript), for example:

     
    u_active=true^ORDERBYu_order

    the results are displayed correctly and sorted as per the u_order field.

  • Scenario 2: When I use a JavaScript reference qualifier, for example:

     
    javascript:'u_dependent_field=' + current.variables.u_services + '^ORDERBYu_order';

    the dependent values are retrieved correctly based on the selected service, but the results are not sorted by u_order — instead, they appear in alphabetical order.

Could you please confirm whether ORDERBY is supported in JavaScript-based reference qualifiers for Lookup Select Box variables in Record Producers, or suggest the recommended way to ensure sorting by a specific field (like u_order) when using a dynamic qualifier?

13 REPLIES 13

The reference qualifier on Services or System doesn't look right, but if you've named this variable the same as a function value that could be working for you, albeit confusing.  The Variable attributes field on Impacted Solution should be

ref_qual_elements=cybersecurity_sap_related

 

 

I agree that the screenshots could cause a bit of confusion. No need to worry about the qualifier — I’ve verified that all the choices are appearing correctly as per the conditions defined in the reference qualifier. I also added the attribute ref_qual_elements=cybersecurity_sap_related as suggested, but the sorting is still not happening according to the defined order.

Is the sort order correct when using this reference qualifier:

javascript:'u_function_code=impacted_solutionRP^u_active=true^ORDERBYu_order';

 

Just to clarify — below  condition correctly retrieves the data, but the ORDERBYu_order is not applying the sort. When I use a static simple reference qualifier (for example: "u_active=true^ORDERBYu_order"), the sorting works as expected. However, when using the JavaScript reference qualifier

javascript:'u_function_code=impacted_solutionRP^u_active=true^u_dependent_field.u_value=' + current.variables.cybersecurity_sap_related + '^ORDERBYu_order';

— the sorting is not happening as per the defined order.

I was interested to see the results of the qualifier I specified as it is combining your simple static example with your intended goal, but removing a potentially problematic condition to see if that is the issue.  Since I demonstrated an example where the format you are attempting does work, the issue is elsewhere.