- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 08:51 AM
the html is:
<g:ui_element table="u_development_standard" field="u_standard" id="466eef750fd3710060017e4ce1050ee2"></g:ui_element><p></p>
the javascript to GET the value is:
var standardId = gel('u_development_standard.u_standard');
but how do I SET the value?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2015 07:26 PM
If you're starting off with an empty list and you want to add to it, you should also see a "_edit" which you're probably aware of since that is the element that contains your actual glide-list and you needed to change the display value to get it to show. Or at least that's what I get and had to do.
So inside of that you'll see the list is actually a simple select element that if not empty would contain option elements. If you want to add/remove to that then you need to do the same as before and capture it via DOM.
I believe the id for the select element would be something like this "select_0u_development_standard.u_standard".
So document.getElementById('select_0u_development_standard.u_standard') should do it. From there you'll need to create an element and stuff it with the desired data. Then append it to the select element. Something like this:
var selEl = document.getElementById('select_0u_development_standard.u_standard');
var optEl = document.createElement('option');
var txtNd = document.createTextNode([your display value if different from actual value]);
optEl.setAttribute('value', [your actual value. usually the sys_id]);
optEl.appendChild(txtNd);
selEl.appendChild(optEl);
All of those values should correlate to what you already have going on with the previous stuff. Of course you can optimize the code so that you can add multiple at a time. I'll leave that up to you though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 11:11 AM
Simon,
Try dot walking to the value.
var standardId = gel('u_development_standard.u_standard');
standardId.value;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 11:15 AM
Strike that. You're looking to set it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 03:17 PM
Okay Simon,
After fiddling with this here is what I came up with. It seems like the <g:ui_element /> is simply used to pull data from a field on a record. I couldn't even do the regular processing with providing a name to the element. So basically to make this work I did what I see many of the baseline scripts do in jelly with UI pages. They use hidden input fields.
Of course this is all under the assumption that you are want to use it like a form and submit it.
The html:
<g:ui_form onsubmit="getInpt()">
<g:ui_element table="u_development_standard" field="u_standard" id="466eef750fd3710060017e4ce1050ee2" />
<input type="hidden" name="u_stand" id="u_stand" /> <!-- new hidden input field to capture new value -->
<g:dialog_buttons_ok_cancel ok='return true' />
</g:ui_form>
The Client Script or within Script tags in the html section of UI page form:
var standardId = gel('u_development_standard.u_standard'); //grab ui_element
var newInpt = gel('u_stand'); //grab input element
function getInpt(){
newInpt.value = standardId.value; //stuff input with user input from ui_element
}
The Processing Script:
var testing = new GlideRecord('u_development_standard');
testing.get('466eef750fd3710060017e4ce1050ee2'); //get record
testing.u_standard = u_stand; //stuff field with new value
testing.update();
var urlOnStack = GlideSession.get().getStack().bottom();
response.sendRedirect(urlOnStack);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 10:14 PM
Use Evaluate in jellyScript to get a GlideRecord object from Back End
<evaluate var="jvar_gr" object="true"
expression= "var gr = new GlideRecord('incident');
gr.setLimit(10);
gr.query();"
/>
<ul>
<j:while test="${gr.next()}">
<li>${jvar_gr.getValue('number')}</li>
</j:while>
</ul>