Adding/Removing option based on assignment group

sasi
Tera Contributor

Hi team,

 

My requirement is to add/remove options based on group. when ABC group is selected there are other two fields called agent and target based on agent selected target has to update the options.

i have created script include and client script but after saving it returning to none

 

script include:

returnIncGroup: function() {
var caseId = this.getParameter('group_id');
var gr = new GlideRecord('table_name');
gr.get(caseId);
if (caseId == gs.getProperty('propertyofgroupname')) {
return true;
} else {
return false;
}
},

 

onchange client script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var grp = g_form.getValue('assignment_group');
    var case_clasif = g_form.getValue('u_target');
    var scr = new GlideAjax('scriptincludename');
    scr.addParam('sysparm_name', 'returnIncGroup');
    scr.addParam('group_id', grp);
    scr.getXML(callback);
 
    function callback(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer=='true'){
g_form.clearOptions('u_target');
        var agnt = g_form.getValue('u_agent');
        if (agnt == '1') {
            g_form.addOption('u_target', '', '-- None --');
            g_form.addOption('u_target', 'Non Associate');
        } else if (agnt == '2') {
         
            g_form.addOption('u_target', '', '-- None --');
            g_form.addOption('u_target', 'Centrally Block Prescriber', 'Block');
            g_form.addOption('u_target', 'Request');
        } else if (agnt == '3') {
       
            g_form.addOption('u_target', '', '-- None --');
            g_form.addOption('u_target', 'Facility');
        }
}
    }
}

 

2 REPLIES 2

RaghavSh
Kilo Patron

In your  script you are not equating your object "ethicsObj" with anything, so why are you gliding then?

Can you paste the actual code here?


Raghav
MVP 2023

sasi
Tera Contributor

Hi Raghav,

 

this is my original script only,can you let me know if the issue with script include?