- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2024 04:33 AM - edited 08-19-2024 09:45 PM
Hello community,
I’m facing an issue with a Reference Qualifier in ServiceNow. It works perfectly on the backend; I can retrieve the parameter values that I pass using current.field_name in the advanced Reference Qualifier, and the script executes as expected.
However, the problem arises on the Service Portal. When I open the same form in the portal, the value selected in field1 should be passed into the Reference Qualifier set on field2. But in the portal, my script returns either null or undefined.
Here’s a brief example:
- Table: Location
- Form Fields:
- field1 - Type: Reference
- field2 - Type: Reference
- The user selects or fills a value in field1.
- In the dictionary, a Reference Qualifier is set for field2, with field1 set as a dependent field, and this is how I am passing value in refernece qualifier script
javascript: new PortalUtil().referenceQualifierForLocation(current.getDisplayValue('field1'), current.getValue('field1'));
(I’ve tried both current.field1 and current.getValue('field1'), but the result is the same.)
Note: In the backend (desktop view), the script include receives the correct value, but on the portal, it returns undefined or null. Also this form is not a catalog item or record producer.
I suspect the issue lies with current, as it might not be available in the portal environment.
Can anyone suggest a workaround or solution for this?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 02:41 AM
Client script UI Type was set to Desktop, just changed it to ALL and Client script now works for Both UI Builder Page and Backend Form. Also added extra 1 sec delay on UI Builder Page Script code.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2024 09:44 AM
In the Service Portal, do you know if your form is custom? If yes, you must create this rule in the widget.
You can do this in 2 ways:
1. Use $sp.getForm on server side of the widget. This function returns to you not only the fields but all rules linked to the form, including your Reference Qualifier.
2. Call your Script Include from the widget server-side and put the return in ngModel of the field.
MVP 2025 ✨
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 09:48 PM
Hi @Isaac Vicentini ,
I might have forgot to mention that, This service portal is developed using UI Builder. So, your mentioned solution might not be applicable here.
Also I am using form component here to open/create table record.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 02:41 AM
Client script UI Type was set to Desktop, just changed it to ALL and Client script now works for Both UI Builder Page and Backend Form. Also added extra 1 sec delay on UI Builder Page Script code.
Thanks