How to populate value in a field on approval table from workflow?

thirumala2
Tera Guru

Hi ,

We have a requirement of populating value from workflow to a given field on approval table for managed docs .

find_real_file.png

From the below workflow run script :

find_real_file.png

@shloke04 can u help ?

 

1 ACCEPTED SOLUTION

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

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

36 REPLIES 36

@thiruma 

This is really interesting, as it is working for me.

I would suggest you can connect with me on Linked In and I can look at your code and will assist you which will be quick as well.

Send me a request on below Linked in profile of me:

https://www.linkedin.com/in/shloke-srivastava-13a1b887/

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Ankur Bawiskar
Tera Patron
Tera Patron

@thirumala 

update as this

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval',current.sys_id);
gr.query();
while(gr.next()){
	gr.u_managed_document = current.number.toString();
	gr.update();
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

Thanks for the response .I have tried this 1 also not working .Is there some other script to be added since that number field is on dms_document table and the wf run on dms_document _revision table .

Hi,

okay workflow is on dms_document_revision table

did you check it went inside

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id',current.sys_id);
gr.query();
if(gr.next()){
    
    gs.info("inside");
    
    gr.u_managed_document = current.number.toString();
    gr.update();
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

No ,The message is not going inside .