- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2022 04:56 AM
Hi ,
We have a requirement of populating value from workflow to a given field on approval table for managed docs .
From the below workflow run script :
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2022 05:49 AM
By mistake I have put a quotes while setting the value. You need to remove that:
Modified script below:
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id',current.sys_id);
gr.query();
while(gr.next()){
gr.FIELDNAME = current.number.toString(); // Replace "FIELDNAME " with the one where you want to set on Approver table
gr.update();
}
Try now should work.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 09:21 AM
Yeah now I see why it is not working for you. This is what I was trying to ask you from my post above that where is your workflow written and where are you generating your approvals.
Reason why it is not working is because the workflow is on "Document(dms_document) table and approvals are generating on Document revision table.
So you need to update your script as below:
var gr = new GlideRecord('dms_document_revision');
gr.addQuery('sys_id',current.sys_id);
gr.query();
while(gr.next()){
updateApprovals(gr.sys_id,gr.document.number);
}
function updateApprovals(documentRevisionID,documentNumber){
var gr1 = new GlideRecord('sysapproval_approver');
gr1.addQuery('document_id',documentRevisionID);
gr1.addQuery('source_table','dms_document_revision');
gr1.query();
while(gr1.next()){
gr1.u_managed_document = documentNumber; // Replace "u_managed_document" with your field Name present in Approval table
gr1.update();
}
}
This should work for you.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 11:31 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 02:57 AM
Okay. Thanks for confirming.
Just update your script as below:
var getDocument = current.document.number.toString(); // This will give you the Document Number as you need
var gr = new GlideRecord('sysapproval_approver);
gr.addQuery('document_id',current.sys_id);
gr.query();
while(gr.next()){
gr.u_manage_document = getDocument; // Replace "u_manage_document" with the field on Approval table where you need to update Document Number
gr.update();
}
I have tested this in my PDI and works fine for me.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 05:16 AM
Hi
I did copied and updated the script its still not working for me .Anything I missed .
var gr = new GlideRecord('sysapproval_approver
I added the inverted comma still the same .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 06:43 AM
Can you share the complete code and also a screenshot of the activity where you are trying to add this code.
The code should work which I have shared, but would ask you to share the screenshot of the code and the activity as well just to make sure you are putting it in right place or not.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke