The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to set value in workflow

RudhraKAM
Tera Guru

Can some one help me with this script

I have a table u_test_results  in which there is a record XYZ1 ( with name as u_name)

I have a catalog item on which we have a variable which is reference field of above table , when a user picks the above record and place a request we need to set a current time on other table 

in the workflow i am writing this script and its not setting the time . Can you please help me fixing this issue .

The other table is u_solution which has 2 fields 

1 closed date and 2.record for (this field contains XYZ record and its a reference field too) 

 

var GOT= parseInt(current.variables.u_name.getDisplayValue());
var gr = new GlideRecord('u_solution ');
gr.addQuery(u_recorded_for, GOT);
gr.query();

if (gr.next()) {
gr.u_closed_date = current.opened_at;
gr.update();
}

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

Updated Script:

 

 


var tenant= new GlideRecord('u_delegated_management_environment');
if(tenant.get('faf6c496dbfd3380cebc550a48961983')) {
var test = tenant.name;


var gr = new GlideRecord('u_mou');
gr.addQuery('u_service.name',test);

gr.query();
while(gr.next()) {

gr.u_end_date=gs.nowDateTime();
gr.update();

}
}

View solution in original post

22 REPLIES 22

Thanks Harsh 

its showing some error message in workflow activity ( u_recorded_for is not defined 

 

logs returning the name and rowcount  returns some sys_id 

 

I double check the name in the table it is correct

"u_recorded_for" it is on which table ? 

can you put the screenshot here of workflow and the field 

U_recorded_for is on u_solution tables which is reference of cmdb_ci

 

current.variables.u_name.getDisplayValue();

is a reference of u_delegate table both the records have same sys_id

 

Hello Harsh 

 

please see this post this is similar to existiing issue

https://community.servicenow.com/community?id=community_question&sys_id=01865a6edb35bb80d58ea345ca96...

is it possible , if you can connect me on webex and share your screen, this way i can quickly try to help you .