- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2016 09:45 PM
Hi All,
I am trying to populate value into a ui_reference field in my UI Page for service catalog.
Below is the code on UI page:
<g2:ui_reference name="u_exec_leadership_team" table="sys_user" value="$[test]" displayvalue="$[name]" onchange="setCartValue();" /> |
So, the page loads with value from "$[test]" and "$[name]" variable.
But I using onchange function in another field on the page to call a UI script function, which changes these value.
So the UI Script function does some evaluation and then set value of 'u_exec_leadership_team'. Below is the code, I used to set the value:
g_form.setValue('u_exec_leadership_team', sys_id);
This gives value to the UI Reference field but display shows as "undefined".
I have tried using "g_form.DisplayValue('u_exec_leadership_team', name);". But it still shows undefined and doesn't show the name.
"name" here is the corresponding name to the above used sys_id.
Am I using the correct syntax to set the Display value for UI page or there is some other method?
Please help.
Thanks
Shihab
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2016 12:30 AM
You can set the display value directly by doing
g_form.setValue('u_exec_leadership_team', sys_id,name);
Where "name" contains your display value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2016 12:20 AM
HI Shihab
Have you tried doing a jslog(sys_id) or alert(sys_id) just to check that your variable actually contains a value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2016 12:25 AM
Hi Lars,
Thanks for your reply.
The variable sys_id, do contains value as it is putting the value to the reference field. It set sys_id of a user in the reference field and I can see that user and go to the record when I click/hover on it. It definitely contains value and also setting the value in the field. But can't set the display value, which should be the name of that user.
Any idea, why that's not happening?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2016 12:30 AM
You can set the display value directly by doing
g_form.setValue('u_exec_leadership_team', sys_id,name);
Where "name" contains your display value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2016 04:46 PM
Hi Lars,
Thanks a lot mate. That worked perfectly.
Thanks again.