
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 09:21 AM
Hello, I have a UI page and I want to populate it with some values on the current selected record that are passed in to it via the UI Action properties.
How can I set the value of the g:ui_reference element on UI page load? The value is succesfully being passed into the jelly variable ${jvar_assignedto}. I can tell because it prints the results on the page Assigned To: ${jvar_assignedto}.
However, I am unable to set a default value of the g:ui_reference. I tried document.getElementById("assignedto_reference").value = user_id; and document.getElementById("assignedto_reference").innerHTML = user_id;
HTML
<g:ui_form>
<!-- Get cmdbci value passed in from the UI Action properties -->
<g:evaluate var="jvar_cmdbci" expression="RP.getWindowProperties().get('cmdbci')" />
<g:evaluate var="jvar_assignedto" expression="RP.getWindowProperties().get('assignedto')" />
Assigned To: ${jvar_assignedto}
Asset: ${jvar_asset}
<g:ui_reference name="assignedto_reference" id="assignedto_reference" table="sys_user" query="active=true^sourceISNOTEMPTY"/>
<input type="hidden" name="dialog_cmdbci" id="dialog_cmdbci" label="Computer" value="${jvar_cmdbci}"></input>
<input type="hidden" name="dialog_user_id" id="dialog_user_id" label="Assigned To User" value="${jvar_assignedto}"></input>
</g:ui_form>
Client Script
var user_id = gel("dialog_user_id").value;
//Populate assigned to user
document.getElementById("assignedto_reference").innerHTML = user_id;
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 09:46 AM
You shouldn't have to use any client side scripting at all. The ui_reference ui macro accepts parameters for setting the default value. You can pass it the sys_id and display value and it will use those as the default value. You might have to do some querying in a g:evaluate in order to grab the displayvalue for your sys_id (or you could pass it). I also don't think id is a valid parameter you can pass.
So your line 7 would look like:
<g:ui_reference name="assignedto_reference" value="${jvar_assignedto}" displayvalue="<the record's display value>" table="sys_user" query="active=true^sourceISNOTEMPTY"/>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 09:46 AM
You shouldn't have to use any client side scripting at all. The ui_reference ui macro accepts parameters for setting the default value. You can pass it the sys_id and display value and it will use those as the default value. You might have to do some querying in a g:evaluate in order to grab the displayvalue for your sys_id (or you could pass it). I also don't think id is a valid parameter you can pass.
So your line 7 would look like:
<g:ui_reference name="assignedto_reference" value="${jvar_assignedto}" displayvalue="<the record's display value>" table="sys_user" query="active=true^sourceISNOTEMPTY"/>