Script Include return always the same value

Hicham Zeriate
Tera Contributor

Hi All,

I have an issue with Script Include - it always return the same value of this variable "iso_short", no matter which value is this variable "name" on this table "core_country "

 

Script include : 

getSite_CountryCode: function() {
        var user = new GlideRecord("sys_user");
        if (user.get(this.getParameter('user') + "")) {
            var result = this.newItem("result");
            //Récupération du CountryCode

            var CountryCode = new GlideRecord("core_country");
            if (CountryCode.get(user.u_country)) {
                result.setAttribute("country", CountryCode.iso_short + "");
 
 
 
client script : 
 
var ga = new GlideAjax("FixPortalCatalogUtilsAJAX");
    ga.addParam("sysparm_name", "getSite_CountryCode");
    ga.addParam("user", g_form.getValue('requested_for'));
    ga.getXML(getResponse);
 
function getResponse(response){
        var result = response.responseXML.getElementsByTagName("result");
        var country = result[0].getAttribute("country");
        var siteName = newValue.toString();
        if(country && siteName){
            //Concaténation de l'adresse Mail
            var EmailAddress = country.replace(/ /g, '_') + '-' + siteName.replace(/ /g, '') + '-' + Description + EmailDomain.replace(/ /g, '_');
            g_form.setValue('DLEmailAddress', EmailAddress);
        }
    }
}
 
6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Hicham Zeriate 

your code will work fine if u_country field on sys_user is referring to core_country table?

if it's reference then simply dot walk and get the value

        var user = new GlideRecord("sys_user");
        if (user.get(this.getParameter('user') + "")) {
            var result = this.newItem("result");
            //Récupération du CountryCode
                result.setAttribute("country", user.u_country.iso_short + "");

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur , thank you for your reply but

 

it's return : undefined

Did you put logs and check for iso value in script include?