Scoped app Jelly scripting, need help passing setPreference value from client script to UI Page

Cris P
Tera Guru

Hi everyone,

I have a client script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}
	
	var sOffering = g_form.getValue('service_offering'); // used in setPreference

	//alert(sOffering);
	
	var ga = new GlideAjax('CPProblemAssociate');
	ga.addParam('sysparm_name', 'probExist');
	ga.addParam('sysparm_so', sOffering);
	ga.addParam('sysparm_mi_state', 'Accepted');
	ga.getXMLAnswer(function(a){
		if (a == 'true'){
			//alert('answer is true');
			var dialog = new GlideModal("x_arl_msp_major_pr_Problem_List");  
			dialog.setTitle("Problem(s) in Progress"); 
			dialog.setPreference("sOfferingSysId", sOffering);  
			dialog.setWidth("100%");
			//dialog.setPreference('record', g_form.getUniqueValue());
			dialog.render();
		}else{
			alert('answer is false');
		}
	});
}

 

<j:jelly trim="false" xmlns:g="glide" xmlns:g2="null" xmlns:j="jelly:core" xmlns:j2="null">

	<style>
		.table1{background-color: #f1f1f1;margin: 20px 0;box-shadow: 0 2px 4px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12) !important; width:100%; text-align:center;}
		.table2 th{padding-left:10px;}
		.table2 tr:hover{background-color: #ffff99;color: black;}

		.button1{background-color: #066599b3 !important;color: white !important;border-color: white;border-radius: 6px;padding: 6px 20px 6px 20px;}
		.pad1{padding:15px !important;}
	</style>	

	<!-- <j:set var="jvar_so_sys_id" value="${RP.getWindowProperties().sOfferingSysId}" /> --> // tried
	<!-- <j:set var="jelly.record" value="${RP.getParameterValue('record')}" /> --> // tried
	<!-- <g:evaluate var="jvar_soffering" expression="RP.getWindowProperties().get('sOfferingSysId')" /> --> // tried
	<g:evaluate var="jvar_so_id" object="true" expression="RP.getWindowProperties().sOfferingSysId" /> // trying
	<g:evaluate object="true">

		//var so = RP.getParameterValue('sOfferingSysId');

		var gr = new GlideRecord("problem");

		gr.addQuery('active','true');
		gr.addQuery('service_offering', ${jvar_so_id}); //jelly.jvar_so_sys_id
		gr.query();
		gr;

	</g:evaluate>
	<p><b>text</b></p>
	<table border="1" style="width:100%" class="table2">
		<thead>
			<tr style="background-color:red!important; color: white;line-height: 30px;">
				<th>Incident</th>
				<th>Location</th>
				<th>Short Description</th>
				<th>Service</th>
				<th>Configuration Item</th>
			</tr>
		</thead>
		<tbody class="mi-options">
			<form>
				<j:while test="${gr.next()}">
					<tr >
						<td>
							<div class="radio">
								<label><input type="radio" name="sys_id" value="${gr.getValue('sys_id')}" onclick="unhide()">${gr.getValue('number')}</input></label>
							</div>
						</td>
						<td>
							${gr.location.getDisplayValue()}

						</td>
						<td>
							${gr.getValue('short_description')}
						</td>
						<td>
							<!-- ${gr.business_service.getDisplayValue()} --> Was b service
						</td>
						<td>
							${gr.getDisplayValue('cmdb_ci')}
						</td>
					</tr>
				</j:while>
			</form>
		</tbody>
	</table>
	<br></br>
	<table width="100%">
		<tr>
			<td width="40%"><button class="button1" type="button" id="link" value="link_mi" onclick="fun()">text</button></td>
			<td width="50%"></td>
			<td width="10%"><button style="float: right;" class="button1" type="button" value="cancel_link" onclick="cancel_link()">Cancel</button></td>
		</tr>
	</table>
	<div id="result"> </div>
</j:jelly>

 

With the above, I am currently getting this error when the UI Page loads up:

'The element type "g2:scope" must be terminated by the matching end-tag "</g2:scope>".'

find_real_file.png

 

All I want to do is pass a value from my onChange client script to my UI page (All in the same scoped app); How can I achieve this?

1 ACCEPTED SOLUTION

Hi there, thanks for your response.

That unfortunately does not work in a scoped UI Page.

I managed to get it to work properly the following way:

<g:evaluate object="true" jelly="true">
		var so = RP.getWindowProperties().sOfferingSysId; //cant use get here
		var gr = new GlideRecord("problem");
		//gr.addQuery('active','true');
		gr.addQuery('service_offering', so); use our preference in query
		gr.query();
		gr;
</g:evaluate>

View solution in original post

2 REPLIES 2

umaaggarwal
Giga Guru
Giga Guru

Hi Cris,

 

Please try like below syntax : 

 

<g:evaluate>
    var incSys = RP.getWindowProperties().get('incident_sys_id');
        </g:evaluate>

 

 

use get after RP.getWindowProperties() and then the value. in your case it is : sOfferingSysId

Hi there, thanks for your response.

That unfortunately does not work in a scoped UI Page.

I managed to get it to work properly the following way:

<g:evaluate object="true" jelly="true">
		var so = RP.getWindowProperties().sOfferingSysId; //cant use get here
		var gr = new GlideRecord("problem");
		//gr.addQuery('active','true');
		gr.addQuery('service_offering', so); use our preference in query
		gr.query();
		gr;
</g:evaluate>