- 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-09-2020 12:23 AM
Hi Kevin,
Is the record producer on User table or some other table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2020 12:25 AM
user table(sys_user)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2020 12:53 AM
In the Record producer's Script field use something as below.
var emailenteredis = producer.email_address; //suppose user enters mail which you need to check is present in User table
var chkuser = new GlideRecord('sys_user');
chkuser.addQuery('email', emailenteredis);
chkuser.query();
if (chkuser.next()) {
chkuser.email = 'abc@gmail.com';
chkuser.mobile_phone = '1234567890';
chkuser.update(); //This updates if match is found & avoids record producer insertion because of below line of code
current.setAbortAction(true); //aborts submission
} else {
var insertuser = new GlideRecord('sys_user');
insertuser.initialize();
insertuser.email = emailenteredis;
insertuser.insert();//creates new record with email address. add additional fields as per need
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2020 01:03 AM
thank you, but the user is not entering anything. The logged in user details from the user table are populated in the variables