- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 09:16 AM
I have a variable on my item , the value of which i am trying to prepopulate onload of the item.
This variable is a single line text & i have given the default value as javascript:gs.getUser().getRecord().getValue('u_business_unit_id');
I basically want to populate the variable with a default value of the business unit id from the user record on load of the item.
Its not working and not returning the value.
Any suggestions?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 09:32 AM
Hi Amol,
Use the following
javascript:
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',gs.getUserID());
gr.query();
if(gr.next()){
gr.u_business_unit_id;
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 10:00 AM
Yep, that's what i did . Added it to the default value & it is working fine now. Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 10:09 AM
Also , will i be able to get a handle to this variable if i keep it hidden by unchecking the visible checkboxes in the Availability section.
I only need the value of it in an email at the end of the workflow process.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 10:20 AM
Yes. You can keep it hidden on the form using UI policy or onLoad Client Script. But dont remove it from the form.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 11:40 AM
Thanks for the input. I used an onload catalog client script to hide the variable. I am able to get a handle to it in a mail script to populate the value of the variable in the email.