Retrieve data from List type field and Update User Data
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2024 11:41 PM - edited ‎02-15-2024 11:42 PM
Hi All,
I'm trying to retrieve the value of the list-type field 'u_product_list' for the user with the role 'customer_admin' whose contact corresponds to the current value. After that, I want to update the product list for the newly created user in the 'customer_contact' table. However, the script provided is not functioning as intended using workflow
var gr = new GlideRecord('sys_user_has_role');
gr.addQuery('role.name', 'sn_customerservice.customer_admin');
gr.addQuery('user.company', current.account);
gr.query();
if (gr.next()) {
var usr = new GlideRecord("customer_contact");
usr.first_name = current.first_name;
usr.last_name = current.last_name;
usr.email = current.email;
usr.phone = current.u_phone_number;
usr.preferred_language = current.u_language;
usr.u_watchlist = current.u_watchlist;
var user_name = current.u_user_id;
var user_name_available = user_name;
var dup = new sn_customerservice.CSPortalUtil().isDuplicateUserID(user_name_available);
if (!dup) {
usr.user_name = current.u_user_id;
usr.account = current.account;
var productList = [];
productList.push(gr.user.u_product_list.getValue().toString());
gs.log(productList);
usr.u_product_list = productList;
var newpw = new sn_customerservice.CSPortalUtil().createPassword();
usr.user_password.setDisplayValue(newpw);
usr.password_needs_reset = true;
var userid = usr.insert();
}
}
Thanks & Regards
Vamshi
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2024 12:00 AM