- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2017 09:01 PM
Hi All ,
Please help with this requirement . I have created catalog Onchange client script to verify the computer name entered by the user on the catalog form. I am making GlideAjax to a script include which inturn will be calling the Powershell script .I am making Synchronous Ajax call so user need to wait for result whether Computer name entered is Valid AD object or not.
The issue I am facing is Once change is made to the Computer name variable , the dialog window is showing as loading but Immediately it comes as "Page not found" shown below . Please help me what changes I need to make to the On Change Catalog client script.
Onchange Catalog Client script:
------------------------------------------
function onChange(control, oldValue, newValue, isLoading) {
if (newValue != '') {
var loadingDialog = new GlideDialogWindow("dialog_loading", true);
loadingDialog.setTitle('Please wait,your computer name is getting verified'); //Set the loading dialog title here...
loadingDialog.render();
var cuser = g_form.getValue('requestor');
//alert(cuser);
var userAjax = new GlideAjax('GenericAJAXUtil');
userAjax.addParam('sysparm_name', 'getUSerDomain');
userAjax.addParam('sysparm_user',cuser);
userAjax.getXML(function(response){
var resp = response.responseXML.documentElement.getAttribute('answer');
//alert(resp);
var cAjax = new GlideAjax('ValidateComputerUtil');
cAjax.addParam('sysparm_name', 'checkcomputer');
cAjax.addParam('sysparm_value1', newValue );
cAjax.addParam('sysparm_value2', resp);
cAjax.getXMLWait();
alert(cAjax.getAnswer().output);
loadingDialog.destroy();
});
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2017 10:14 PM
There seems to be some issue with loading_dialog macro as well. Its mentioned that its no longer working after fuji release. Below thread seems to have a code from UI Macro which can be used ti create a new UI page and then it should work when you pass the ui page name in the GlideDialoWindow.
Re: Show/Hide Loading Dialog on shopping cart submit
Above should help you to fix the page not found error but further you need to work on your code to get it working properly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2017 09:40 PM
I will suggest to merge the code for these two script includes and make a single AJAX call. What is happening in your code is ... your first glideAjax call is asynchronous so the code below get executed without waiting for the response from 1st call. So value of resp should be null when you are passing it as parameter in 2nd ajax call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2017 09:44 PM
Hi Gurpreet,
Please let me know if I need to make first Ajax also as Synchronous. Please suggest the changes in the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2017 09:47 PM
Hi Gurpreet,
Please see below .
This is my first script include:
var GenericAJAXUtil = Class.create();
GenericAJAXUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUSerDomain: function (){
var domain='';
var user = this.getParameter('sysparm_user')+'';
gs.log("RequestorAdmin :"+user);
var user_gr = new GlideRecord('sys_user');
user_gr.addQuery('sys_id',user);
user_gr.query();
if(user_gr.next()){
domain = user_gr.u_domain.u_name+'';
gs.log("Domainfinal :"+domain);
}
return domain;
},
type: 'GenericAJAXUtil'
});
This is my Second Script include:
var ValidateComputerUtil = Class.create();
ValidateComputerUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkcomputer: function (){
var cname = this.getParameter('sysparm_value1')+'';
gs.log("computer name :"+ cname);
var domain = this.getParameter('sysparm_value2')+'';
gs.log("domain user :"+ domain);
// risc
var mid = gs.getProperty('mid.server.name2');
gs.log("MID Server :"+mid);
var server = '127.0.0.1';
var scr = "scripts\\PowerShell\\ValidateADComputer.ps1";
gs.include("PowershellProbeWithParameters");
var inputParameters = [cname, domain];
gs.log("InputParm :"+inputParameters);
var powershell = new PowershellProbeWithParameters(mid, server, inputParameters);
powershell.setScript(scr);
var response = powershell.execute(true);
gs.log("powershell response :"+response.output+response.error);
return response;
},
type: 'ValidateComputerUtil'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2017 09:55 PM
Hi Gurpreet,
Please suggest how can I merge the two script include . As I am having another client calling the first Script include for showing/hiding a field.
Please let me know how to merge these two and use for GlideDialog.