Script include to query a record and set the value of specific field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 12:39 AM
Hi Team,
We need a script include to query 'sysapproval_approver' table and check if approval type is parallel.
For those records, we need to set the field 'parallel approvals intiated' as true from client script by calling above script include.
below screenshot is for your reference:
Please help with the code
Thanks,
Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 06:16 AM
Are you initiating this from a task form ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 06:29 AM
Hi,
Nope, this has written on sysapproval table.
Please help!
Thanks,
Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 06:54 AM
Can we please have a call?
I can explain you in brief!
This is quite urgent!
Thanks,
Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2022 01:35 AM
Hi Muhammed,
Can you please help on this?
Thanks,
Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 01:10 AM
Hello,
Please check if below helps you:
Put the below script in your client script onLoad, onChange or onSUbmit as per your need:
if (newValue) {
var ga = new GlideAjax('CustomApprovalUtils');
ga.addParam('sysparm_name', 'updateApprovalRecord');
ga.getXMLAnswer(parseRecievedResponse);
}
function parseRecievedResponse(answer) {
if (answer) {
alert("APPROVAL RECORD UPDATED");
}
}
Script INclude where client callable is checked, I am not sure if this will work because if some user who is not having access to update the Approval record and that user tries to execute the update the I think ACL will restrict. You can check once and confirm
var CustomApprovalUtils = Class.create();
CustomApprovalUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
updateApprovalRecord: function() {
var recordUpdated = "";
var sysApprovalGR = new GlideRecord('sysapproval_approver');
sysApprovalGR.addEncodedQueryQuery('PUT YOUR QUERY');
sysApprovalGR.query();
while(sysApprovalGR.next()){
sysApprovalGR.setValue('<parallel_approvals_initiated_field_name>', true);
recordUpdated = sysApprovalGR.update();
}
return recordUpdated;
}
type: 'CustomApprovalUtils'
});
Please mark my respsone as helpful/correct, if it answer your question.
Thanks