- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 05:38 AM
Hi,
In my ui page, I have my HTML script as:
<g:evaluate var="jvar_productSysId" expression="RP.getWindowProperties().get('sysparm_product_sys_id')" />
<g2:evaluate object="true">
var productType = new GlideRecord("cmdb_ci_business_app");
productType.addQuery("sys_id", $[jvar_productSysId]);
productType.query();
if(productType.next()){
var productFamily = productType.apm_application_family;
</g2:evaluate>
<input type="hidden" id="productFamilyValue" name="productFamilyValue" value="${productFamily}"></input>
and in client script i am trying to get alert:
alert(gel('productFamilyValue').value);
But this is not working.
How can i use this value in client script ?
Also, this variable 'productFamily' should give sys id . I want display value as well.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2022 05:40 AM
Hi,
update as this to get display value
HTML:
<j:set var="jvar_productSysId" value="${JS:RP.getWindowProperties().get('sysparm_product_sys_id')}" />
<g:evaluate object="true" jelly="true">
var productFamily;
var productType = new GlideRecord("cmdb_ci_business_app");
productType.addQuery("sys_id", jelly.jvar_productSysId);
productType.query();
if(productType.next()){
productFamily = productType.apm_application_family.getDisplayValue();
productFamily;
</g2:evaluate>
<input type="hidden" id="productFamilyValue" name="productFamilyValue" value="${productFamily}"></input>
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
07-30-2022 09:08 AM
Hi Ankur,
I tried this but i am not getting any value in alert.
<g:evaluate var="jvar_productSysId" expression="RP.getWindowProperties().get('sysparm_product_sys_id')" />
<g:evaluate object="true" jelly="true">
var productFamily;
var productType = new GlideRecord("cmdb_ci_business_app");
productType.addQuery("sys_id", jelly.jvar_productSysId);
productType.query();
if(productType.next()){
productFamily = productType.apm_application_family.getDisplayValue();
productFamily;
</g:evaluate>
<input type="hidden" id="productFamilyValue" name="productFamilyValue" value="${productFamily}"></input>
In client script:
alert(gel('productFamilyValue').value); //No value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 10:15 PM
Hi Ankur,
How can i check if i am getting any value in jelly.jvar_productSysId ?
I tried this <p>${jelly.jvar_productSysId} </p> but do not see any value coming.
I am getting value in <p>${jvar_productSysId}</p> after 1st <g:evaluate>
Also tried to pass hardcoded value for sys id but still no value is coming in alert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 10:23 PM
Hi,
it should work fine ideally and you should get the value of jvar_productSysId in 2nd g:evaluate
share your complete script
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
07-31-2022 10:34 PM
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<g:evaluate var="jvar_productSysId" expression="RP.getWindowProperties().get('sysparm_product_sys_id')" />
<p>${jvar_productSysId}</p> //getting this value
<input type="hidden" id="productSysId" name="productSysId" value="${jvar_productSysId}"></input>
<g:evaluate object="true" jelly="true">
<!--var sysparm_product_sys_id = RP.getParameterValue('sysparm_product_sys_id');
<p>$[sysparm_product_sys_id]</p>
<p>jelly.jvar_productSysId</p>
<p>${jelly.jvar_productSysId}</p>
<p>${jvar_productSysId}</p>-->
var productFamily;
var productType = new GlideRecord("cmdb_ci_business_app");
productType.addQuery("sys_id",jelly.jvar_productSysId');
productType.query();
if(productType.next()){
productFamily = productType.apm_application_family.getDisplayValue();
productFamily;
}
</g:evaluate>
<input type="hidden" id="productFamilyValue" name="productFamilyValue" value="${productFamily}"></input>
<div id='mydiv1' onchange="showHide(this)">
<label id='label1' >Project type?</label><br/>
<input type="radio" name="project_type" id="yes" value='yes' mandatory="true" >Yes</input><br/>
<input type="radio" name="project_type" id="no" value='no' >No</input><br/><br/>
</div>
<div class="modal-footer" id="dialog-buttons">
<span class="pull-right">
<button class="btn btn-default" id="cancel_button" onclick="cancelDialog(); return false" style="min-width: 5em;" type="submit">
${gs.getMessage('Cancel')}
</button>
<button class="btn btn-primary" id="ok_button" onclick="return submitDialog()" style="min-width: 5em;" title="" type="submit">
${gs.getMessage('Submit')}
</button>
</span>
</div>
</g:ui_form>
</j:jelly>
client script:
function showHide(object) {
alert(gel('productFamilyValue').value);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 12:02 AM
Hi,
you had quotes in this line; so I removed it
productType.addQuery("sys_id",jelly.jvar_productSysId);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader