Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Store html value in jelly script variable

arey yaar
Giga Guru

On the below script I want to set the number value which is in html text field into the jelly script variable "jvar_number", but the below code didnt work, am i missing something.

Client script:-
addLoadEvent(function() {
    var url = top.location.href;
    var number = new URLSearchParams(url).get("sysparm_number");
gel('number').value=number;
}

Html:-
	<input type="text" id="number"/>
	<j:set var="jvar_number" value="${document.getElementById('number').value}"/>
	test:-${jvar_number}
3 REPLIES 3

Jack
Tera Guru

Hi,

Seems to be you want to get number from URL, so, I think you needn't scripting at client script side;

Just use Jelly script to get URL param (add this block above your logic), example as below:

 <j:set var="jvar_number" value="${RP.getParameterValue('sysparm_number')}" />

 Hope this help!

Hi Jack,

 

Thanks for your response.

 

Since im using the Ui page on an Iframe , "RP.getParameterValue("sysparm_number") " is not working.

 

Just wonder if there is any special reason that you want to set back value to jelly object.

As my knowledge, jelly is run at server-phase, then control return to browser client-phase.

I suggest you can try switch your logic to use Jquery client script.

Or can you share your requirement here? ==> then other guys can have overview and see if there is another way to achieve this