- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 09:54 PM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 10:10 PM
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
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 10:10 PM
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
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 10:31 PM
Hello @Vishal Birajdar
I solved the problem with the information you gave me.
Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 10:18 PM - edited 01-30-2024 10:20 PM
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....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 10:28 PM
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