- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 01:21 PM
I do not usually work within the Workflow Editor. And I'm not a great scripter, so of course that's what I must work with right now!
We have added a rejection reason onto the approval form.
We have created a new request form for our customers to request Non-Standard Software.
Within the workflow, there is an approval step. To reject the request, we require a reason. If it is rejected, then the request is canceled and the user is notified.
It's the "run script" step I am struggling with. I wrote a very simple script to retrieve the rejection reason and set it in the current record.
var rejectReason = new GlideRecord('sysapproval_approver');
rejectReason.addQuery('document_id',current.sys_id);
rejectReason.addQuery('state', 'rejected');
rejectReason.query();
if(rejectReason.next()) {
current.cancel_reason = rejectReason.u_rejection_reason;
current.setWorkflow(false);
current.update;
}
I'm fairly confident by issue is with the last few lines. I'm just not sure what the appropriate syntax should be.
Any help would be most appreciated!
Warren Baltimore
Solved! Go to Solution.
- Labels:
-
Workflow Automation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 02:22 PM
Well, I solved it. I went a different route with this-
var rejectReason = new GlideRecord('sysapproval_approver');
var tgtRec = new GlideRecord('u_atf_new_software');
rejectReason.addQuery('document_id',current.sys_id);
rejectReason.addQuery('state', 'rejected');
rejectReason.query();
if(rejectReason.next()) {
tgtRec.addQuery('sys_id',current.sys_id);
tgtRec.query();
if(tgtRec.next()) {
tgtRec.u_cancel_reason = rejectReason.u_rejection_reason;
tgtRec.autoSysFields(false);
tgtRec.update();
}
}
Works quite well!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 02:22 PM
Well, I solved it. I went a different route with this-
var rejectReason = new GlideRecord('sysapproval_approver');
var tgtRec = new GlideRecord('u_atf_new_software');
rejectReason.addQuery('document_id',current.sys_id);
rejectReason.addQuery('state', 'rejected');
rejectReason.query();
if(rejectReason.next()) {
tgtRec.addQuery('sys_id',current.sys_id);
tgtRec.query();
if(tgtRec.next()) {
tgtRec.u_cancel_reason = rejectReason.u_rejection_reason;
tgtRec.autoSysFields(false);
tgtRec.update();
}
}
Works quite well!