- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2020 12:13 AM
I have a requirement to create a record producer to update the user table. When the record producer is opened, the person who is logged in, all his data from the user table are automatically populated in their related variables of the record producer, then the user can update the values and on submit , the existing record in the user tables gets updated without creating a new record. Can someone help me on this? On how to start?
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2020 12:24 AM
Hi Kevin,
Please follow the below steps, your requirement will be fulfilled:
1. First, create a record producer and create all the necessary variables in the record producer.
2. Create an onload script, to update all the logged-in user details in the Record Producer.
3. Write Record Producer script, such that first if should query the User table to check the record exists for the Logged-in user or not. If exist simply update the fields what he has updated in Record producer, If the record doesn't exist then simply create a record in User Table.
Please Feel free, to ping me if you stuck somewhere.
Please mark it as Correct/Helpful if it fulfills your requirement
Thanks
Vamshidhar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2020 07:11 AM
update as below
remove variables from every place
Script Include:
var user = {
"user_name" : gr.user_name.toString(),
"first_name": gr.first_name.toString(),
"last_name": gr.last_name.toString(),
"email": gr.email.toString(),
"mobile_phone" : gr.mobile_phone.toString(),
"company" : gr.company.toString(),
"title" : gr.title.toString(),
"manager": gr.manager.toString()
};
return JSON.stringify(user);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2020 07:50 AM
It worked, can you tell why those changes were needed? and what was wrong with mine?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2020 07:53 AM
gr.variables or gliderecord_object.variables is used to fetch variable values from RITM record
but here you are using query to sys_user table so that would cause the script not to work.
Let me know if I have answered your question.
Please mark my response as correct and helpful to benefit future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2020 08:12 AM
Thanks for marking my response as helpful.
Please close the question as answered by marking my response as correct.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 01:26 AM
I tried the same for asset table, where I get all the asset records of the logged in user and based on the no of records returned I returned some value to the client script. The client script uses the value to populate the variables of the record producer. But, whatever the value is returned from the script include is showing as null and the variable is not populating. Can You tell me what is wrong? I have attached the script