[this.getParameter] cannot be used. ..

__17
Tera Expert

I'm trying to run a server script I created in a script include using "Glide Ajax" in a client script.

 

 

<Client script>

 function test() {

    var inputVal = confirm('Do you want to run the process?');

    if (inputVal) {
        var ga = new GlideAjax('Server_script_name');
        ga.addParam('parameter1',g_form.getUniqueValue());
        ga.getXML();
    }

}

 

<Script include>

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

    run_script: function() {

    var tmp_msg = this.getParameter('parameter1');
            gs.addInfoMessage(tmp_msg );

   }

});

 

How can I pass a value from a client script to another script?

1 ACCEPTED SOLUTION

Also you need to update script include part at the end.

missing below line:

  type: 'Server_script_name'

 

Your Script include should be like below:

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

    run_script: function() {

    var tmp_msg = this.getParameter('parameter1');
gs.info(tmp_msg);
            gs.addInfoMessage(tmp_msg );

   },
type: 'Server_script_name'
});

Thanks,

Anil Lande

View solution in original post

4 REPLIES 4

Anil Lande
Kilo Patron

Hi,

Update the script include part like below:

 function test() {

    var inputVal = confirm('Do you want to run the process?');

    if (inputVal) {
        var ga = new GlideAjax('Server_script_name');
      ga.addParam('sysparm_name','run_script');  // call server side function using this line, it is mandatory
        ga.addParam('parameter1',g_form.getUniqueValue());
        ga.getXML();
    }

}

 

Thanks,
Anil Lande

Also you need to update script include part at the end.

missing below line:

  type: 'Server_script_name'

 

Your Script include should be like below:

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

    run_script: function() {

    var tmp_msg = this.getParameter('parameter1');
gs.info(tmp_msg);
            gs.addInfoMessage(tmp_msg );

   },
type: 'Server_script_name'
});

Thanks,

Anil Lande

Anil Lande
Kilo Patron

Hi,

Alos, please use check below link to learn more about GlideAjax functionality.

https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f961...

 

Thanks,

Anil Lande

Ankur Bawiskar
Tera Patron

Hi,

I would suggest you to go through the ServiceNow documentation around GlideAjax

AJAX

Regards
Ankur