Pass value from Client Script to Processing script UI Pages

Surbhi Srivasta
Tera Expert

Hi,

I have an UI page where on click of a button , field value needs to change. This is working and I am doing this using a Processing script in my UI Page.

Problem is, I need to make the processing script wait until client script confirms.

 

Basically, how can I pass value from client script to my processing script, so that my processing script does not get trigger instantly.

This is what I have tried so far

 

1. I have declared the Hidden variable similar to yours.

2. I have a processing script which is getting executed, but I need to check a certain value which I need to pass from my client script and then only Processing script should get executed.

 

HTML:

<input type="hidden" id="jvar_answer" name="jvar_answer" value=""/>
<g:dialog_buttons_ok_cancel ok_text="${gs.getMessage('Send')}" ok="actionOK();" cancel="return cancel();"/>

Client Script:

function actionOK() {
    var getMessage = new GlideAjax('SI Name');
    getMessage.addParam('sysparm_name', 'Method Name');
    getMessage.addParam('sysparm_recordID', g_form.getUniqueValue());
    getMessage.getXMLAnswer(getMessageInfo);
}

function getMessageInfo(answer) {
	alert(answer); //getting the alert successfully here

    if (answer != '') {
        if (confirm(getMessage(answer)) == true) {
            gel('jvar_answer').value = "confirmed";
        } else {
            gel('jvar_answer').value = "cancel";
        }

    }
}

Process Script:

gs.info("value of Hidden variable is " + jvar_answer);

 

I am getting the message as blank in the info statement put in processing script.

 

Regards,

Surbhi

7 REPLIES 7

Hi @Ankur Bawiskar 

Hidden input is within the g:form tags only. Apologies for not including it here. Please see the complete code:

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">
<g:ui_form>
<input type="hidden" id="jvar_answer" name="jvar_answer" value=""/>
 </g:ui_form>-->

 

Still it does not wwork. AM i missing something here?

 

Regards,

Surbhi

@Surbhi Srivasta 

you said you are doing GlideAjax call from client script.

Why not invoke the script include from processing script and pass the value which you are passing the ajax function as function parameter?

you can pass values from client script to processing script section using hidden elements.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, 

Can you please tell how we can pass value to processing script from client script and HTL both