How to get record producer sys id into a variable set ?

shabbir5
Tera Guru

Hi,

I have a variable set in that created a variable called 'price' which is a single line text.( i want to use that variable set into multiple record producers)

for the variable price i want default value as sys id of that record producer.

i tried on degault value: , javascript:current.sys_id ,and producer.sys_id but no luck , please share if you have any idea on this.

Thank you

Shabbir

1 ACCEPTED SOLUTION

RaghavSh
Kilo Patron

Try with on load catalog client script:

g_form.setValue('price', g_form.getUniqueValue());


Raghav
MVP 2023

View solution in original post

9 REPLIES 9

RaghavSh
Kilo Patron

Try with on load catalog client script:

g_form.setValue('price', g_form.getUniqueValue());


Raghav
MVP 2023

hi raghav, i tried the same but not workig

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

You cannot get it directly via default value

you will have to set it via form load catalog client script

1) Create one onLoad Catalog Client script which Applies to variable set

Script below This would work in native and portal both

function onLoad() {
	//Type appropriate comment here, and begin script below
	if(window != null){
		var cat_id = gel('sysparm_item_guid').value;
		g_form.setValue('price', cat_id);
	}
	else{
		var val = g_form.getUniqueValue();
		g_form.setValue('price', val);
	}
}

Regards
Ankur

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

hi ankur ,

it is not working ,i tried.

//Shabbir