
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2022 08:38 PM
Hi,
I'm trying to create a problem record related to the incident that the user is accessing, through an UI Action in the incident table. This UI Action calls a Glide Modal that requests the user to fill in an information in a checkbox field. This information filled in the selection box will be used in one of the fields of the problem that will be created.
I already created the UI Page that the modal uses (image 1 of the attachments and code below) and I also created the UI Action that calls the Modal (image 2 of the attachments and code below). But I can't find a way to get the value that was filled in the modal and use it in a glide record to create a problem record related to the current incident. Can you help me ?
UI Page Code:
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">
<g:ui_form>
<table>
<tr>
<td style="width:50%">
<g:form_label>
Select Category of Problem:
</g:form_label>
</td>
<td style="width:60%">
<g:ui_choicelist name="prb_category" id="prb_category" table="problem" mandatory="true" field="category" query="inactive=false"/>
</td>
</tr>
<tr>
<td>
<g:dialog_buttons_ok_cancel ok_id="submitData" ok="return continueOK()" ok_type="button" ok_text="${gs.getMessage('Criar Problema')}" ok_style_class="btn btn-primary" cancel_type="button" cancel_id="cancelData" cancel_style_class="btn btn-default" cancel="return continueCancel()"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client Script
function continueOK(){
var gdm = new GlideModal().get();
var categoria = gel('prb_category').value;
GlideModal().get().destroy();
}
function continueCancel(){
GlideModal().get().destroy();
}
UI Action Code:
function modalTest(){
var storeValue;
var gm = new GlideModal('create_problem_ui_action');
gm.setTitle('Selecionar Categoria do Problema');
gm.render();
}
How modal is displayed on incident form:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 08:19 PM
Hi,
to make the modal disappear do this
GlideDialogWindow.get().destroy();
in order to populate you can use GlideRecord to update the current record
So final code
function continueOK(){
var categoria = gel('prb_category').value;
// your logic to insert problem
// ensure you store the newly problem record sysId in variable problemSysId
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', g_form.getUniqueValue());
gr.query();
if(gr.next()){
gr.problem_id = problemSysId;
gr.update();
}
GlideDialogWindow.get().destroy();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2022 09:04 PM
Hi,
are you not able to get the choice value using this?
do you wish to associate this problem with the current incident i.e. populate the newly created problem in the incident problem_id field?
function continueOK(){
var gdm = new GlideModal().get();
var categoria = gel('prb_category').value;
alert(categoria);
// you can do the GlideRecord here to insert
GlideModal().get().destroy();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2022 06:16 AM
Hi @Ankur, Yes, I am getting the choice value using gel().value. I also created the glide record and its working when I click on the button that trigger the continueOK() function.
But I am still having two issues:
1. After I click on the buttons (OK or Cancel) the modal is still displaying, it doesnt disappear/get destroyed. -> RESOLVED
2. How can I populate the current problem_id incidente field with the new created problem ? Can I use the anotation current on this client script to access the current incident ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 08:19 PM
Hi,
to make the modal disappear do this
GlideDialogWindow.get().destroy();
in order to populate you can use GlideRecord to update the current record
So final code
function continueOK(){
var categoria = gel('prb_category').value;
// your logic to insert problem
// ensure you store the newly problem record sysId in variable problemSysId
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', g_form.getUniqueValue());
gr.query();
if(gr.next()){
gr.problem_id = problemSysId;
gr.update();
}
GlideDialogWindow.get().destroy();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader