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

find_real_file.png

I am adding in run script and I have also used .tostring () also

find_real_file.png

@thirumala 

Not an issue. Let us debug this becuase the script looks correct to me unless something else might be making it not to work:

Can you put some logs as shown below and let me know what is coming in these log statements:

var getDocument = current.document.number.toString(); // This will give you the Document Number as you need
gs.info(Document Number is '+ getDocument);
var gr = new GlideRecord('sysapproval_approver);
gr.addQuery('document_id',current.sys_id);
gr.query();
while(gr.next()){
gs.info(Approval Record are '+ gr.sys_id);
gr.u_managed_document = getDocument; // Replace "u_manage_document" with the field on Approval table where you need to update Document Number
gs.info(Managed Document number are '+ gr.u_managed_document);
gr.update();
}
gs.info(Updated Managed Document number are '+ gr.u_managed_document);

Please test with these 4 different log statement and tell me what you are getting in these 4 statements.

Please share screenshot as well for these 4 statement

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

find_real_file.png

Hi @shloke04 these messages i HAVE GOT IN LOGS.

Hi @thirumala 

There were other two info statement in the script above? Did you check what are we getting in the statements below:

gs.info(Approval Record are '+ gr.sys_id);
gs.info(Managed Document number are '+ gr.u_managed_document);

Let me know what you are getting in these log statements.

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

Ya @shloke04 I have checked these 2 messages are not reflecting in logs .I have checked multiple times .