ORG ID

Rajesh77
Tera Contributor

Hi Team,

 

I have a catalog item where the workstation type should select the correct one i.e for my ORG id (ORG01234) the Entity_SubscopeId(SSC051) the default is "Yes" and workstation type is Skynote

When i try it in the catalog item it automatically populates NEO that is not the correct one, it should populate Skynote, i have written on change catalog client script given below 

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

   g_form.clearOptions('workstation_type');
    //g_form.addOption('workstation_type','--None--','--None--');
    
    
var user = g_form.getReference('requested_for',callback);
    function callback(user){
        var country = user.u_country;
        //g_form.addInfoMessage("user country is :" +country);
        
    
    var ga = new GlideAjax('GetWorkstationType');
    ga.addParam('sysparm_name''checkOrgID');
    ga.addParam('sysparm_user', newValue);
    ga.addParam('sysparm_user_country', country);
        //ga.addParam('sysparm_type',type);
    //ga.addParam('sysparam_arche',g_form.getValue('archetype'));
    ga.getXML(function(response) {
       // alert("getxml");

        var msg = response.responseXML.documentElement.getAttribute('answer').split(',');
        //var result = JSON.parse(msg);
        //if(result.def=='Yes'){
       for (var i = 0; i < msg.length; i++) {
          //alert("line 27cs" +msg.work);
         // if(msg.d=='Yes'){
             // alert("line 29"+msg.d);
            g_form.addOption("workstation_type", msg[i],msg[i]); 
            
         // }   
      
    //}
       }
        g_form.removeOption('workstation_type','[object Object]');
    
    });
}
}

 

Rajesh77_0-1691505540677.png

Rajesh77_1-1691505942728.png

 

Please assist me further.

 

 

1 REPLY 1

Tushar
Kilo Sage
Kilo Sage

Hi @Rajesh77 

 

some more changes -

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    g_form.clearOptions('workstation_type');
    
    // Get user country synchronously
    var user = g_form.getReference('requested_for');
    var country = user.u_country; // Assuming u_country is the correct field name
    
    var ga = new GlideAjax('GetWorkstationType');
    ga.addParam('sysparm_name', 'checkOrgID');
    ga.addParam('sysparm_user', newValue);
    ga.addParam('sysparm_user_country', country);
    
    ga.getXML(function(response) {
        var msg = response.responseXML.documentElement.getAttribute('answer').split(',');
        
        for (var i = 0; i < msg.length; i++) {
            g_form.addOption("workstation_type", msg[i], msg[i]);
        }
        
        // After adding options, remove [object Object] option if any
        g_form.removeOption('workstation_type', '[object Object]');
    });
}

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar