Copy fields value from one record to another on the same table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2021 04:53 AM
Hi,
On the User form, there is a manager reference field that reference another user.
When creating (or updating) a user (from service catalog item or directly from the users list) and populate the manager field, i need 2 things :
- Copy some fields values from the manager form to the user form. If the manager change, the fields value change too.
- If fields values are changed on the manager form, it should update all the fields values on the users who have this manager.
I thought about business rules but i don't know how to do this.
Regards,
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2021 08:19 PM
Instead on Submit, If the fields are on the form use onChange client script on Manager field on the catalog item. You can use getReference or GlideAjax to fill the fields on the form.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var user=g_form.getReference('manager',setFields);
function setFields(user){
g_form.setValue('field1',user.field1);
g_form.setValue('field12',user.field2);
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2021 07:16 AM
Please close this thread.