- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 08:23 PM
I have a record producer variable 'company' which mapping to incident table 'company' , I want to make this variable automatically populate 'company' variable when user load the request form in service portal. How to do it?
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 09:27 PM
Hi,
based on logged in user?
if yes then you can use default value in that variable; I assume that variable is of type reference
javascript: gs.getUser().getCompanyID();
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
‎08-02-2022 02:03 AM
yes, the record producer variable is also reference field and referring to 'Company' table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 02:35 AM
Write an OnLoad client script as below
function onLoad() {
var now_GR = new GlideRecord('sys_user');
now_GR.addQuery('sys_id', g_user.userID);
now_GR.query(response);
function response(result) {
if (result.next()) {
g_form.setValue('company', result.getValue('company'));
}
}
}
Mark as correct and helpful if it solved your query.
Regards,
Sumanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 02:36 AM
Hi Betty,
Write an OnLoad client script as below
function onLoad() {
var now_GR = new GlideRecord('sys_user');
now_GR.addQuery('sys_id', g_user.userID);
now_GR.query(response);
function response(result) {
if (result.next()) {
g_form.setValue('company', result.getValue('company'));
}
}
}
Mark as correct and helpful if it solved your query.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 05:07 AM
Hi Betty,
Did you try above solution?
Feel free to reach out if you have further questions or else you can mark an answer as correct and helpful to close the thread so that it benefits future visitors also.
Regards,
Sumanth