Refresh an UI Page with client script

Jeff60
Kilo Expert

Hello everyone.

My question is about UI Page on a Request Item or Task
I would like to refresh a Variable type "UI Page" as soon as there is a change in the value of a "Select box" type variable.

find_real_file.png

But i don't know how to do it properly.

Thanks in advance for your help 😉

11 REPLIES 11

Use this: I've done with incident table. Replace it with yours.

Also from you catalog client script call the constructTable(), 

UI Page:

HTML:

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

	
	<div id="myTable"></div>
	
	
</j:jelly>

 

 

Client Script:

constructTable();

function constructTable() {

    var ga = new GlideAjax('FinancialStuff');
    ga.addParam('sysparm_name', 'getTableFormat');
    ga.getXML(getResponse);

}

function getResponse(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
    $j("#myTable").html(answer);

}

 

 

Script Include:

var FinancialStuff = Class.create();
FinancialStuff.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    
	getTableFormat : function()
	{
		var htmlData = '<table><tr><td style="border:1px solid black">Number</td><td style="border:1px solid black">Short Description</td><td style="border:1px solid black">Priority</td><td style="border:1px solid black">Description</td></tr>';
		var inc = new GlideRecord("incident");
		inc.setLimit('5');
		inc.query();
		while (inc.next()) {
			htmlData = htmlData + '<tr><td style="border:1px solid black">' + inc.number+ '</td><td style="border:1px solid black">' + inc.short_description + '</td><td style="border:1px solid black">' + inc.priority + '</td><td style="border:1px solid black">' + inc.description + '</td></tr>';
		}
		
		return htmlData;

	}
	
});

AnirudhKumar
Mega Sage
Mega Sage

Hey Jeff,

Did the code work?

Hello @AnirudhKumar 

Trying to find a solution with you 😉

Thanks in advance.

Oops... missed the posts.

I'm back on this...

This UI Page is on the variable editor of your RITM correct?

And OnLoad of the RITM form, the constructTable() function should be called and script include should return you some HTML stuff.

What do you get when you alert answer variable in the getResponse function?

 

Also in your script include function getTableFormat, please add the closing tag '</table>' to the htmlData variable. 

The variable gfa_ag2, is being used to get the parameter and is also used as a GlideRecord object. Use a different variable for one of them.

 

Please send the updated code here...