- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2018 10:56 PM
Hi All,
I am using g_form.getReference to populate users details in a catalog item via client script. For a few fields in user profile like Business Unit, Department, cost center, I am getting the sys_id instead of the display value.
Since these fields are reference field , the value returned is sys id. How can i get the display value instead of the sys id.
var user= g_form.getReference('requested_for');
g_form.setValue('business_unit',user.u_business_unit.u_name); ///business unit is a reference field on user table
I understand i can use asynchronous glide record in the client script to populate. but not sure if that is recommended
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2018 11:52 PM
Hi Priyanka,
I think the best way to achieve this is by using Glide Ajax. Send the sysid to the script include, query the tables and return all the display values in an array.
Thanks,
Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2018 06:13 AM
Hi thank you for your assistance, i ended using glideajax to fullfill this requirement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2018 11:21 PM
Hey Priyanka,
for gating actual value from reference field in client script we have g_form.getDisplayBox(field_name).value
use this script and let me know if any query regarding this.
var gr = g_form.getReference('requested_by', findMyDetails);
function findMyDetails(gr)
{
g_form.setValue('your_field_name', gr.mobile_phone);
g_form.setValue('your_field_name', gr.email);
g_form.setValue('your_field_name', gr.city);
var man=g_form.getDisplayBox('manager').value;//manager field is reference field so you need to do something like that.
g_form.setValue('your_field_name', man);
g_form.setValue('country', gr.country);
}
HOPE THIS HELPFUL!!!!! MARK CORRECT OR HELPFUL.
Thanks,
Mohammed Iqbal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2018 11:46 PM
hi mohammed, i think g_form.getDisplayBox('manager').value would work if the field is in the current logged in form. However, in my case , i am intending to fetch the display value of a reference field thats present on another(user) table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2018 12:45 AM
I have tried at my end its working fine.
var caller = g_form.getReference('requested_by', doAlert);
function doAlert(caller) {
g_form.setValue('manager', caller.department);
}
in above example manager field is reference field and it is referring to cmn_department table.
suppose if you want to fetch the department of requester and you want to set the value of department in your other custom field then your custom field should be same as department field which is present in user table.
your custom field is referring to the cmn_department table and it should be reference field.
HOPE THIS HELPFUL!!!!! MARK CORRECT OR HELPFUL.
Thanks,
Mohammed Iqbal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2018 11:52 PM
Hi Priyanka,
I think the best way to achieve this is by using Glide Ajax. Send the sysid to the script include, query the tables and return all the display values in an array.
Thanks,
Arun