- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2015 11:54 PM
Hi,
I have a script include and catalog client script that instantiates and access the script include. Problem is, it does not return the value.
Script Include
==========
var acn_catalogClientScripts = Class.create();
acn_catalogClientScripts.prototype = {
initialize: function() {
this.errorMessage = "";
},
sampleFunction: function(){
return "SampleAnswer!";
},
type: 'acn_catalogClientScripts'
};
Catalog client script
=================
var validation = new gacn_catalogClientScripts();
var validation_result = validation.sampleFunction();
g_form.addErrorMessage("Value is " + validation_result);
validation_result does not return anything. Please help. Do I really have to use GlidAjax for this? As per my understanding, accessing script include can be done this way.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2015 01:59 AM
All i know is initialize is the function coming from super class and they mentioned on wiki like
- Avoid overriding methods of AbstractAjaxProcessor, including initialize. While it is possible to invoke methods of your superclass object which you have overridden, it is complicated and best avoided altogether.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2015 12:20 AM
Now I am enlightened. Server to server only. Thanks Gurpreet Singh!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2015 12:29 AM
Hi Gurpreet Singh,
I tried using GlideAjax but it still does not return anything.
function onLoad() {
g_form.clearMessages();
var validation = new GlideAjax('acn_catalogClientScripts');
validation.addParam("sysparm_name","sampleFunction");
validation.getXMLWait();
g_form.addErrorMessage("Answer is" + validation.getAnswer());
}
It seems validation.getAnswer() does not return anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2015 12:33 AM
change statement g_form.addErrorMessage("Answer is" + validation.getAnswer()); with
alert("Answer is" + validation.getAnswer())
Also share the script include in not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2015 12:48 AM
Hi Gurpreet Singh,
Below is my updated codes:
Script include
=====================
var acn_catalogClientScripts = Class.create();
acn_catalogClientScripts.prototype = Object.extendsObject(AbstractAjaxProcessor, {
initialize: function() {
this.errorMessage = "";
},
sampleFunction: function(){
return "SampleAnswer!";
},
type: 'acn_catalogClientScripts'
});
Catalog Client Script
=====================
function onLoad() {
g_form.clearMessages();
var validation = new GlideAjax('acn_catalogClientScripts');
validation.addParam("sysparm_name","sampleFunction");
validation.getXMLWait();
alert("Answer is " + validation.getAnswer());
}
Output
===========
"Answer is null"
Why is the answer null when I have returned a pre-defined string?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2015 01:01 AM