Updating a field by getting input from dialog window.

saranyadevic
Kilo Contributor

Hi all,

I have requirement .we have incident record when we right click that record it has to show custom UI action called update priority.if I click that it has open a dialog window and it should have field called priority with options..if select any priority and tries to submit .once submitted that priority should needs to update in original record.

for that i have created

UI action :

function updatePriority() {

var sysId = typeof rowSysId == 'undefined' ? gel('sys_uniqueValue').value : rowSysId;

var input_priority = gel('priority');

var gDialog = new GlideDialogWindow("inc_update_priority");

gDialog.setTitle("Update Priority");

gDialog.setPreference('sysparm_sysID', sysId);

gDialog.setPreference('sysparm_table', "incident");

gDialog.setPreference('input_priority',input_priority);

gDialog.render();

}

Ui page : inc_update_priority

Html :

<g:ui_form>

<input type="hidden" id="incidentSysID" name="incidentSysID" value="${sysparm_sysID}"/>

    <!-- Get the values from dialog preferences -->

      <g:evaluate var="jvar_comments_text"

      expression="RP.getWindowProperties().get('comments_text')" />

    <!-- Set up form fields and labels -->

    <table width="100%">

   

        <tr>

            <td>

                <!-- Comments text field (Contains comments from originating record as a default) -->

              <select name="priority" id="priority" mandatory="true" value="${jvar_comments_text}" >

  <option value="1">1 - Critical</option>

  <option value="2">2 - High</option>

  <option value="3">3 - Moderate</option>

  <option value="4">4 - Low</option>

</select>

            </td>

        </tr>

        <tr>

            <td colspan="2">

            </td>

        </tr>

        <tr id="dialog_buttons">

              <td colspan="2" align="right">

                    <!-- Add OK/Cancel buttons. Clicking OK calls the validateComments script -->

                    <g:dialog_buttons_ok_cancel ok="return validateComments()" ok_type="button" cancel_type="button" />

              </td>

          </tr>

  </table>

</g:ui_form>

Client Script :

function validateComments() {

    //This script is called when the user clicks "OK" in the dialog window

    var priority = gel("priority").value;

alert(+priority);

    }

    GlideDialogWindow.get().destroy();

This Ui action is updating the priority , when i checked as form button, in list view its not updating the priority, can anyone please help

1 ACCEPTED SOLUTION

Hi Saranya,



yes GlideRecord works in client script of ui page.


Also use window.location.reload(); instead of location.reload()



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

function validateComments() is in client side of Ui page,



can i use gliderecord over there?



even if i try that shows error in 'location.reload();'


Hi Saranya,



yes GlideRecord works in client script of ui page.


Also use window.location.reload(); instead of location.reload()



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Yes its working  



Thank you Ankur Bawiskar