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

try

var GOT= 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.u_recorded_for = current.sys_id;
	gr.update();
}

its showing run script error 

 

stating that  u_recorded_for is not defined 

Prateek kumar
Mega Sage

//var GOT= parseInt(current.variables.u_name.getDisplayValue()); //Why this line??

var GOT= current.variables.u_name; 
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();
}


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Thanks Prateek , The code didnt work šŸ˜ž

Harsh Vardhan
Giga Patron
var GOT= current.variables.u_name.getDisplayValue();
gs.log('The Value is'+GOT);
var gr = new GlideRecord('u_solution');
gr.addQuery('u_recorded_for',GOT);
gr.query();
gs.log('Row Count'+gr.getRowCount());
if (gr.next()) {
	gr.u_closed_date = current.opened_at;
	gr.u_recorded_for = current.sys_id;
	gr.update();
}

 

try now and let me know the log details.