- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 12:24 PM
I have a client script running on sc_task table. I need to get the RITM number to pass to a Glide Ajax call.
I am using "var ritm = g_form.getValue('current.request_item.number');" but it is not returning a value.
What am I coding wrong or incorrect dot walking in line 6.
whole script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var status = g_form.getValue('current.variables.comp_reviewStatus');
var ritm = g_form.getValue('current.request_item.number');
alert("The selected reveiw status is " + status + " for " + ritm);
var ritmStatus;
switch (status) {
case "under_review":
ritmStatus = 2; // state = Work in Progress
alert("On the Under Review branch");
break;
case "awaiting_client":
ritmStatus = 5; // state = Awaiting Client
alert("On the Awaiting Client branch");
break;
case "job_builder":
ritmStatus = 18; // state = Awaiting Job Builder
alert("On the Awaiting Job Builder branch");
break;
case "completed":
ritmStatus = 2; // state = Work in Progress
alert("On the Completed branch");
break;
}
// ajax script call to set State on RITM
var setState = new GlideAjax('SHR_set_RITM_State');
gaTitle.addParam('sysparm_name', 'setState');
gaTitle.addParam('sysparm_ritm', ritm);
gaTitle.addParam('sysparm_status', ritmStatus);
//gaTitle.getXML(Job_Answer);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 12:46 PM
Totally agree with the above comment. In addition to that you can also use getReference if you need the RITM Number
g_form.getReference("request_item", getRITMNumber);
function getRITMNumber(ritms){
var ritm = ritms.number;
var status = g_form.getValue("comp_reviewStatus");
alert("The selected review status is " + status + " for " + ritm);}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 12:41 PM
If you are calling a GlideAjax endpoint anyway, you can just move the logic to get the RITM based on the Catalog Task into the client callable Script Include.
As for your script, there is no current client side, and one cannot dot-walk client side.
To get the RITM number, or any information about it, you have two options:
- add the needed field to the form (hide it with a UI Policy if not really needed or in the way) and then you can just use g_form.getValue() or
- add the info to the scratchpad in a display business rule.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 12:46 PM
Totally agree with the above comment. In addition to that you can also use getReference if you need the RITM Number
g_form.getReference("request_item", getRITMNumber);
function getRITMNumber(ritms){
var ritm = ritms.number;
var status = g_form.getValue("comp_reviewStatus");
alert("The selected review status is " + status + " for " + ritm);}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 02:17 PM
Thanks for your response. I changed up my client script to use your function, added a switch to deal with status and then a GlideAjax call to a script include to update the sc_req_item record.
Working now.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 12:49 PM
You cannot use current in a client script. It's a variable from a Business Rule.
You could use g_form.getUniqueValue() to get the sys_id of this record. Then put it into a Ajax param and request the RITM with a Glide Record in your Script Include.