- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 04:54 AM
Hi All 🙂
I'm trying to implement a UI Action on incident which allows the user to specify a field value from on a glidelist from the core_ company table.
What I'm trying to get, is for the UI action to bring up a dialog box allowing the user to select drop a drop down list that will then populate a field on the incident record. The choices in the drop down list would need to be populated by the values in the list field on the linked company record.
I have the dialog box part working, I've also got the UI action passing over the company SID, Incident number and the value (the actual field value, not the display value) from the company.u_list field.
What I need help with is getting the UI page to either look up the company.u_list field to populate the dropdown and show the display value (not the field value) and pass that value back to the incident record.
Thanks in advance,
Patrick
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 10:25 AM
I was able to figure this one out by using Jelly. Here is the code got the HTML on the UI Page:
<g:ui_choice_input_field name="3rd_party">
<option value="">${gs.getMessage('-- None --')}</option>
<g:evaluate var="jvar_item" expression="
var gr = new GlideRecord ('core_company');
gr.get(RP.getWindowProperties().get('company'));
gr.query();
var option = gr.u_3rd_parties;
var listarray = option.split(','); "/>
<j:forEach items="${listarray}" var="jvar_list2">
<option value="${jvar_list2}">${jvar_list2}</option>
</j:forEach>
</g:ui_choice_input_field>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 05:55 AM
Greetings Patrick,
I was having trouble following what you are doing. Perhaps you can share an image so that others can more easily follow and any of the UI page script you already have.
If I understood, you are getting the fields values - not display values - but the field in question is a list field which doesn't natively have the ability to give display values via scripting. You will need to look up those sys_id's on the table that list is referencing to then get the display values of those (which is what things like the list collector does for you)
-Andrew Barnes
Join me at Developer Blog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 06:44 AM
Hi Andrew,
It might be easier if I elaborate what I'm trying to do.
We have a number of 3rd parties that we will need to "outsource" tickets too, and that list varies depending on each company. So On the company table we have a "glide_list" field on the core_company table called "u_3rd_parties", this list dictates which 3rd parties are available to the company.
So what I would like to do is have a UI Action called "Outsource" which brings up a dialog box asking the user to select the 3rd party from a drop down list. This drop down list will be populated by the selected 3rd parties from the u_3rd_parties field on the company table. Once selected, the user will click ok, which will populate a field on the Incident record which will trigger a specific business rule for integration.
Here is currently what I have configured (note this is just a copy of the current version, I've been playing with it).
Hope this makes it clearer.
UI Action (Client side) - Outsource
function outsourceform(){
var company = g_form.getValue('caller_id.company');
var inc = g_form.getValue('number');
var gr = new GlideRecord ('core_company');
gr.get(company);
gr.query();
var list = gr.u_3rd_parties;
var d = new GlideModal('outsource_dialog', false);
d.setTitle('Outsource Ticket to a 3rd Party');
d.setPreference("company", company);
d.setPreference("list", list);
d.setPreference("inc", inc);
d.setSize(400,300);
d.render();
}
UI Page - outsource_dialog
HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<!-- Get values from dialog preferences passed in -->
<g:evaluate var="jvar_company" expression="RP.getWindowProperties().get('company')" />
<span id="var3">Company: ${jvar_company}</span>
<br />
<g:evaluate var="jvar_list" expression="RP.getWindowProperties().get('list')" />
<span id="var2">3rd Parties List: ${jvar_list}</span>
<br />
<g:evaluate var="jvar_inc" expression="RP.getWindowProperties().get('inc')" />
<span id="var1">Ticket Ref: ${jvar_inc}</span>
<br />
<br />
<g:dialog_buttons_ok_cancel ok="return update3rdParty()"/>
</j:jelly>
Client script
function update3rdParty() {
var outsourceparty = gel('3rd_party').value;
g_form.setValue('u_3rd_party', outsourceparty);
g_form.save();
GlideDialogWindow.get().destroy(); //Close the dialog window
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 07:33 AM
In theory what i need is a way to filter a choicelist based on the select choices on the company record.
For example, using the below shows almost gives me exactly what I need but it shows all choices, I need to filter it on the ones selected on the company record.
<g:ui_choicelist class="form-control" name="3rd Parties" table="core_company" field="u_3rd_parties" />
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 10:25 AM
I was able to figure this one out by using Jelly. Here is the code got the HTML on the UI Page:
<g:ui_choice_input_field name="3rd_party">
<option value="">${gs.getMessage('-- None --')}</option>
<g:evaluate var="jvar_item" expression="
var gr = new GlideRecord ('core_company');
gr.get(RP.getWindowProperties().get('company'));
gr.query();
var option = gr.u_3rd_parties;
var listarray = option.split(','); "/>
<j:forEach items="${listarray}" var="jvar_list2">
<option value="${jvar_list2}">${jvar_list2}</option>
</j:forEach>
</g:ui_choice_input_field>