UI Action to update catalog variables value in request Item

SHA3
Giga Expert

I have created a UI action to fetch a field in RITM catalog variables and show in Glidedialogwindow and when user enters value it needs to be updated in the field.

Using below steps:

Ui Action of client type:

function updateInput(){

  var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;

  var dialog = new dialogClass("change_value_popup");

  //dialog.setWidth("800");

  dialog.setTitle(getMessage("Change the value with appropriate"));

  dialog.setPreference('sysparm_sys_id', g_form.getUniqueValue());

  dialog.render(); //Open the dialog.

}

===========================================================================================================

UI Page XML:

<?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:evaluate var="group_mailbox"

      expression="RP.getWindowProperties().get('current.variables.mailbox')" />

  <tr>

                      <td class="label">

                              ${gs.getMessage('Please provide appropriate value:')}

                      </td>

                      <td>

                             

  <g:ui_input_field name="mailbox_name" id="mailbox_name" label="Group Mailbox Name" value="${group_mailbox}"

                      />

    </td>

                </tr>

                <tr>

                      <td>

                              <g:dialog_button id="submit_button" type="submit"

                                onclick="entervalue('${sysparm_id}', this)">${gs.getMessage('Submit')}</g:dialog_button>

                              <g:dialog_button id="cancel_button" type="submit"

                                onclick="closevalueWindow(this)">${gs.getMessage('Cancel')}</g:dialog_button>

                      </td>

                </tr>

      </j:jelly>

Ui Page Client Script:

function closevalueWindow() {

  GlideDialogWindow.get().destroy();

}

function entervalue() {var groupmailbox = gel("mailbox_name").value;

  alert(groupmailbox);

    if (groupmailbox == "") {

          alert("Please enter your value before submitting.");

          return false;

    }

    var req_item = g_form.getUniqueValue();

  alert(req_item);

  var ga = new GlideAjax('AutomationUtils');

  ga.addParam('sysparm_name', 'Changevalue');

  ga.addParam('sysparm_sysid',req_item);

  ga.addParam('sysparm_groupmailbox',groupmailbox);

  ga.getXMLAnswer(getresponse);

  function getresponse(answer){

  closevalueWindow();

  g_form.save();

  }

}

==============================================

Script Include function:

Changevalue: function() {

  var mailbox = this.getParameter('sysparm_groupmailbox');

  var sysid = this.getParameter('sysparm_sysid');

  var req = new GlideRecord('sc_req_item');

              req.get('sysid');

  req.variables.mailbox = mailbox;

  req.update();

  return true;

  new Workflow().broadcastEventToCurrentsContexts(req, 'update', null);

  },

This is failing on the update of catalog variable in RITM.

The need here is to allow the appropriate catalog variable to be shown on Glidedialogwindow for certain selection when Request was submitted(i have not yet gone to the part of querying based on selection bit) and the popup to accept the value and update the variable and workflow to be restarted from that point.

Appreciate your response.

1 ACCEPTED SOLUTION

I am using g_form.setValue('variable name', value) and this is working to set my solution.



Thanks for your time and help Kristen.


View solution in original post

11 REPLIES 11

Thank you. I have tried this, got it from SNGuru



But i need to show only the field i need to be updated as per requirement. Also, view applies to show up other fields as well.



Need to update only Variables section, can Variables section alone be shown in the pop-up ?



find_real_file.png


I am using g_form.setValue('variable name', value) and this is working to set my solution.



Thanks for your time and help Kristen.