UI Page: get the sysId of the calling form in Processing Script

andy_dufresne
Tera Expert

Hello Gurus,

I have form on which we have a 'send SMS' button, when clicked will bring up a UI page, which has a code something like this ..

<g:ui_form>

<input type="hidden" id="cancelled" name="cancelled" value="false"/>

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

<table>

<tr>

<td id="label.location" class="label" nowrap="true" height="23px" type="string" choice="0"><span id="status." class="mandatory label_description" mandatory="true" oclass="mandatory">$[SP]</span><label for="location" onclick="" dir="">Users:</label></td>

<td nowrap="true"><g:ui_reference name="location" id="location" table="sys_user" onchange="user_data()"/></td></tr>

</table>

<table width="100%" cellpadding="0" cellspacing="0">

<tr><td nowrap="true"><g:ui_input_field label="First Name" name="first_name" id="first_name" mandatory="true" size="50" /></td></tr>

<tr><td nowrap="true"><g:ui_input_field label="Last Name" name="last_name" id="last_name" mandatory="true" size="50" /></td></tr>

<tr><td nowrap="true"><g:ui_input_field label="Email" name="email" id="email" mandatory="true" size="100"/></td></tr>

<tr><td nowrap="true"><g:ui_input_field label="Business Phone" name="phone" id="phone" mandatory="true" size="40" /></td></tr>

</table>

<table width="100%" cellpadding="0" cellspacing="0">

<tr><td nowrap="true"><g:ui_input_field label="SMS Text" name="sms_text" id="sms_text" mandatory="true" size="50" /></td></tr>

</table>

<table width="100%" cellpadding="0" cellspacing="0">

<tr><td align="left" nowrap="true"><br /><g:dialog_buttons_ok_cancel ok="return validateForm()" ok_type="submit" cancel="return onCancel();"/></td></tr>

</table>

</g:ui_form>

I want to do a gs.addInfoMessage() on the sys_id of the calling form [aka the form where the 'send sms' button was there].   how do i get it in the   Processing script?

There is more functionality I can implement once I get the sys_id.

Any help?

Thanks in Advance

1 ACCEPTED SOLUTION

Here are the changes. I have tested and it is working


UI action:


function smsDialog() {


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


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


var gDialog = new GlideDialogWindow("Send_sms"); ////Render the dialog containing the UI Page


gDialog.setTitle("Send SMS");


//gDialog.setPreference("incidentSysID", g_form.getUniqueValue());


gDialog.setPreference('sysparm_sysID', sysId);


//gDialog.setPreference('sysparm_table', "incident_alert");


gDialog.render();


}


UI page:


<g:ui_form>


<input type="hidden" id="cancelled" name="cancelled" value="false"/>


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


<!--<g:evaluate var="jvar_incidentSysId" expression="RP.getWindowProperties().get('incidentSysId')" />-->


<!--<input type="hidden" id="incidentSysID" value="${jvar_incidentSysId}" />   -->


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


<table>


<tr>


<td id="label.location" class="label" nowrap="true" height="23px" type="string" choice="0"><span id="status." class="mandatory label_description" mandatory="true" oclass="mandatory">$[SP]</span><label for="location" onclick="" dir="">Users:</label></td>


<td nowrap="true"><g:ui_reference name="location" id="location" table="sys_user" onchange="user_data()"/></td></tr>


</table>



<table width="100%" cellpadding="0" cellspacing="0">


<tr><td nowrap="true"><g:ui_input_field label="First Name" name="first_name" id="first_name" mandatory="true" size="50" /></td></tr>


<tr><td nowrap="true"><g:ui_input_field label="Last Name" name="last_name" id="last_name" mandatory="true" size="50" /></td></tr>


<tr><td nowrap="true"><g:ui_input_field label="Email" name="email" id="email" mandatory="true" size="100"/></td></tr>


<tr><td nowrap="true"><g:ui_input_field label="Business Phone" name="phone" id="phone" mandatory="true" size="40" /></td></tr>


</table>



<table width="100%" cellpadding="0" cellspacing="0">


<tr><td nowrap="true"><g:ui_input_field label="SMS Text" name="sms_text" id="sms_text" mandatory="true" size="50" /></td></tr>


</table>




<table width="100%" cellpadding="0" cellspacing="0">


<tr><td align="left" nowrap="true"><br /><g:dialog_buttons_ok_cancel ok="return validateForm()" ok_type="submit" cancel="return onCancel();"/></td></tr>


</table>


</g:ui_form>


View solution in original post

14 REPLIES 14

Thanks Ankur,



I did try that, it did not return any value, is this correct though?



I also tried   <input type="hidden" id="incidentSysID" value="${jvar_incidentSysID}" />



Hi Andy,



Are you sending the incidentSysId to this ui page?


if yes then you can get that and set it as below:



incidentSysId in the get() method is the same you are sending to the ui page



<g:evaluate var="jvar_incidentSysId" expression="RP.getWindowProperties().get('incidentSysId')" />



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



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

Thanks Ankur, I will try now and let you know.   Thanks for quick response!   I kinda agree with you will let you know shortly!


This is what I have in the 'Send SMS' button:


find_real_file.png



I have this in the 'HTML' part of the UI Page:


find_real_file.png



and I have this in the



find_real_file.png



Nothing exciting about the blocked line it only sends SMS   from a certain number.   and the result is this 😞


find_real_file.png


Hi Andy,



In the html section add the lines i mentioned below


<g:evaluate var="jvar_incidentSysId" expression="RP.getWindowProperties().get('incidentSysId')" />



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



in the processing script add here.


if(incidentSysID != ''){



gs.addInfoMessage('Sys id is:'+incidentSysID);



}



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