- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 06:18 AM
Hello,
On the CSM/FSO workspace, when I create a child quality control task from a parent complaint case that already has the response field (complaint_response) populated, I'd like the response field of that child task to immediately be populated with the response of the parent complaint case. For example here, "test123" in the response field of the parent complaint case should be automatically copied over to the response field of the child QCT.
I've created a script include and an onload client script on the Quality Control Task table (sn_bom_compl_qc_task) that calls the script include. Only the first two alerts are triggering.
Client script:
function onLoad() {
alert('Client script loaded');
var parentCase = g_form.getValue('parent');
alert('Parent case sys_id: ' + parentCase);
if (parentCase) {
// Call Script Include to handle GlideRecord logic
var response = xxUtils.getComplaintResponse(parentCase);
if (response) {
g_form.setValue('complaint_response', response);
alert('complaint_response field updated');
}
}
}
Script include:
getComplaintResponse: function(parentCase) {
var response = '';
var grParent = new GlideRecord('sn_bom_compl_service');
if (grParent.get(parentCase)) {
response = grParent.getValue('complaint_response');
}
return response;
},
type: 'xxUtils'
What am I doing wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 06:38 AM - edited 05-03-2024 08:33 AM
I suggest you look at OOB examples of 'onLoad' client scripts that use GlideAjax to run server-side code and return a value.
Look at client scripts that run "onLoad" and the script contains "g_form.setValue()" and script contains "GlideAjax". Your script include 'xxUtils' needs to create a class as in the above, and you client script needs to reference/invoke that as shown in the client script example above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 06:38 AM - edited 05-03-2024 08:33 AM
I suggest you look at OOB examples of 'onLoad' client scripts that use GlideAjax to run server-side code and return a value.
Look at client scripts that run "onLoad" and the script contains "g_form.setValue()" and script contains "GlideAjax". Your script include 'xxUtils' needs to create a class as in the above, and you client script needs to reference/invoke that as shown in the client script example above.