- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 09:10 AM
Hi All,
I want to fetch phone field(contains code eg: +91 for India, +65 for Sweden) value which will be based on country selection both fields are present on cmn_location table.
I also have another field called country on catalog item which is a lookup selectbox referring cmn_location.
Can someone please suggest what is wrong with the script. I'm getting empty value in gr.phone.
Onchange Client Script on country field:
Script Include :
Thanks in advance!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 10:45 AM
Hello @Ankita9 ,
1.) In the client Script line no. 9 you have passed the cou variable in the single parenthesis. So remove the parenthesis. - ga.addParam("sysparm_country", cou);
2.) In client script, line no. 13 replaced with-
var answer = response.responseXML.documentElement.getAttribute("answer");
3.)In the Script include after gr.query(); you haven't add code for if block.
Please refer following code for that,
getPhone: function() {
var ph;
var loc = this.getParameter('sysparm_country');
var gr = new GlideRecord("cmn_location");
gr.addQuery("country", loc);
gr.query();
if (gr.next()) {
ph = gr.phone;
}
return ph;
},
Please mark as helpful if my answer is helpful to you.
Thanks !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 10:45 AM
Hello @Ankita9 ,
1.) In the client Script line no. 9 you have passed the cou variable in the single parenthesis. So remove the parenthesis. - ga.addParam("sysparm_country", cou);
2.) In client script, line no. 13 replaced with-
var answer = response.responseXML.documentElement.getAttribute("answer");
3.)In the Script include after gr.query(); you haven't add code for if block.
Please refer following code for that,
getPhone: function() {
var ph;
var loc = this.getParameter('sysparm_country');
var gr = new GlideRecord("cmn_location");
gr.addQuery("country", loc);
gr.query();
if (gr.next()) {
ph = gr.phone;
}
return ph;
},
Please mark as helpful if my answer is helpful to you.
Thanks !