set reference field value using flow designer

Shrinidhi Amin
Tera Contributor

I have a text field variable in catalog .

I want to set the text field value to the  parent field of cmdb relationship table which is a reference field using flow designer.

Can someone suggest some solution .

Urgent requirement

 

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

not possible directly. but why to have it as text variable. If user doesn't give valid name the parent field cannot be set.

parent field is reference to cmdb_ci table so you will have to set sys_id in that field only

you will have to use inline f(x) script

script would look something like this

I assume user would enter name of CI which can be found in cmdb_ci table

var sysId = fd_data.trigger.current.sys_id;

var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', sysId);
gr.query();
if(gr.next()){
	var name = gr.variables.enter_name;
	var rec = new GlideRecord('cmdb_ci');
	if(rec.get('name', name)){
		return rec.getUniqueValue();
	}
}

regards
Ankur

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

View solution in original post

9 REPLIES 9

Maik Skoddow
Tera Patron
Tera Patron

Hi

unfortunately it is not really clear what your issue is.

Please provide more details and especially screenshots, so we can better understand your situation and help you accordingly.

Kind regards
Maik

Hello Maik

I have added the attachment 

Can you let me know how can I do it

 

Shrinidhi Amin
Tera Contributor

@Ankur Bawiskar 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

not possible directly. but why to have it as text variable. If user doesn't give valid name the parent field cannot be set.

parent field is reference to cmdb_ci table so you will have to set sys_id in that field only

you will have to use inline f(x) script

script would look something like this

I assume user would enter name of CI which can be found in cmdb_ci table

var sysId = fd_data.trigger.current.sys_id;

var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', sysId);
gr.query();
if(gr.next()){
	var name = gr.variables.enter_name;
	var rec = new GlideRecord('cmdb_ci');
	if(rec.get('name', name)){
		return rec.getUniqueValue();
	}
}

regards
Ankur

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