How to get the value of Variable in Variable Set

Takumi Ando
Tera Contributor

I have a question about the Record Producer script.
I have a variable set for the user information input section that can be used in other catalogs.
I would like to get the value in the variable set and set it to the field in the record when I create the record, How do I write a record producer script?

1 ACCEPTED SOLUTION

Vishal Birajdar
Giga Sage

Hello @Takumi Ando 

 

You can use like below :

 

var variable_1 = producer.variable_name; //to get variable value

current.setValue('field_name', variable_1);  //set value on record

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

6 REPLIES 6

Vishal Birajdar
Giga Sage

Hello @Takumi Ando 

 

You can use like below :

 

var variable_1 = producer.variable_name; //to get variable value

current.setValue('field_name', variable_1);  //set value on record

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Hello @Vishal Birajdar 

I solved the problem with the information you gave me.
Thank you very much.

Sohail Khilji
Kilo Patron
Kilo Patron

Dear @Takumi Ando,

 

All your variables from variable set can be access via producer.name_of_your_varaible;

 

Lets say you have a 'Requested for' field in your  variable set you can access the value of 'requested for' variables and set the value in target record as below.

 

 

var req_for = producer.requested_for; 
current.setValue('u_requested_for', req_for);  

 

 

Producer object is used to access your variables

Current object is used to access your target record fields.

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Aniket Chavan
Tera Sage
Tera Sage

Hello @Takumi Ando ,

To harness the power of your Record Producer, leverage producer.variable_name to seamlessly access the desired variable. Subsequently, employ current.setValue to gracefully imprint this valuable user input onto your record field.

 

//to get variable value
var userInput = producer.variable_name;

 //set value on record
current.setValue('field_name', userInput);

 

 

Let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,
Aniket