Whats wrong with this script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2025 07:22 PM
Hello All,
I am trying to sync a variable "Primary Requested for" (primary_requested_for) created on a catalog form to the RITM requested for field (requested_for) using a catalog client script and a script include.
However its not working as expected. When i submit the form, i still see my name in the requested for on RITM instead of primary requested for's name.
Can someone please advise?
Catalog client script:
Type: On Submit
Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2025 08:29 PM
Hi @dvelloriy
If you prefer not to automatically set the "Requested For" field to the user submitting the request, you can create a "Requested For" type variable in your catalog item. This will allow the requester to select a user, and that selected user will then be mapped to the "Requested For" field in the RITM.
Requested for type variable:
Now coming to your script. As you mentioned in the script comments, the sys id of the form changes after submission.
That's why it's not giving you the expected output.
Sys id from On Submit client script:
Sys id of the actual RITM record:
Hope this helps.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2025 11:44 PM
Hi @J Siva creating a requested for type variable works fine. However when i create the request from an incident through service operations workspace, it gives an error that the following mandatory field is not provided RITM requested for.
is there a way to resolve that sys id issue ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2025 12:07 AM - edited ‎03-22-2025 12:13 AM
Ahh ok understood. I don't think we can achieve that using catalog client script.
Instead you can create a after business rule on sc_req_item. In the condition, you can mention "item = <catlog item>". So that it'll be triggered only for the requests which satisfy the condition.
And in the script condition you can write below script
current.requested_for = current.variables.primary_requested_for;
current.update();
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2025 08:31 PM
Hello @dvelloriy
I don't think catalog client script is the right element for this. Please use " On Load Client script" directly on sc_req_item table. You won't need all this.
var primaryRequestedFor = gForm.getValue('primary_requested_for');
if (primaryRequestedFor) {
gForm.setValue('requested_for', primaryRequestedFor);
}
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY