How can I get the sys_id for a variable in a workflow?

Mark_Bailey
Mega Guru

I am trying to get a variable sys_id in a workflow. I am setting many variable from the work flow but getting the sys_id for this one variable is not working for me.  How can I get the variable sys _is for this one variable in the workflow?

var gateway = current.variables.Gateway.getValue();

var ritm_sys_id = current.sys_id.getValue();

var ritm = current.number.getValue();

var ans_state_sys_id = current.variables.AnsState.sys_id;    (How can I get the sys_id for this variable? )

1 ACCEPTED SOLUTION

Can we try something like this?

var gateway = current.variables.Gateway.getValue();

var ritm_sys_id = current.sys_id.getValue();

var ritm = current.number.getValue();

var ans_state_sys_id = current.variables.AnsState; 

var gr = new GlideRecord('item_option_new');
gr.addQuery('name',ans_state_sys_id);
gr.addQuery('cat_item','sys Id of catalog item');
gr.query();
if(gr.next()){
	var ans = gr.sys_id.toString()
}

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

View solution in original post

4 REPLIES 4

Mark_Bailey
Mega Guru

FYI the variable type is a Yes/No if that makes a difference.

Can we try something like this?

var gateway = current.variables.Gateway.getValue();

var ritm_sys_id = current.sys_id.getValue();

var ritm = current.number.getValue();

var ans_state_sys_id = current.variables.AnsState; 

var gr = new GlideRecord('item_option_new');
gr.addQuery('name',ans_state_sys_id);
gr.addQuery('cat_item','sys Id of catalog item');
gr.query();
if(gr.next()){
	var ans = gr.sys_id.toString()
}

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

meeraj
Tera Contributor
Use scratchpad : workflow.scratchpad.variableName = variableValue;

meeraj
Tera Contributor
workflow.scratchpad.taskid = task.setNewGuid();