Url parameters not working in client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2024 12:49 PM - edited 10-07-2024 06:24 PM
I am trying to load the page with its results by getting parameter 'ban' from url and autopopulate it and do search and
I accept button.
My client script is working for the url
https://xxxxx.service-now.com/sn_ind_tmt_orm_boss_ew_services_search.do?ban=7000001588
with ban parameter, it is performing search service operation + I accept button automatically and display the results accordingly.
But when I am trying to add ban parameter in following url
https://xxxx/now/nav/ui/classic/params/target/sn_ind_tmt_orm_boss_ew_services_search.do?ban=7000001588
it just keep loading,
the difference between two urls is 1st one is without servicenow instance headers and second one is with headers. I want url to be worked with servicenow headers. So do you have any idea, why it is not working and what could be the solution.
Here is my client script:
function onLoad(){
//Populate the variables with the parameters passed in the URL
//Use the 'getParmVal' function below to get the parameter values from the URL
var ban_num = getParameterValue('ban');
if (ban_num) {
g_form.setValue('u_ban', ban_num);
var ban1 = g_form.getValue('u_ban');
if(ban1){
searchService();
setState();
}
}
}
function searchService() {
}
function setState() {
var ga = new GlideAjax('sn_ind_tmt_orm.C360cpni'); //Scriptinclude
ga.addParam('sysparm_name', 'C360cpni'); //Method
ga.addParam('sysparam_ban', ban);
ga.addParam();
ga.getXMLAnswer(getResponse1);
}
function getResponse1(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//var answer = response;
alert(answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2024 02:59 PM
What version of SN are you running and what application is that table in? I'm assuming you are using the built-in search form for the "sn_ind_tmt_orm_boss_ew_services" table, correct? As far as I know, client-scripts do not run within that page, so I'm not sure how your first URL is "working".
Are you seeing any errors in the browser's console?
Also, seeing as you are using "getXMLAnswer", you do not need to use "responseXML.documentElement.getAttribute()", and in fact, not sure what it would return. You should be good with the "var answer = response" that you have commented out. But again, I'm 99.9% sure Client Scripts DO NOT run on the search page.