List collector field reference of country table by selecting china , usa automatically populated

sonypaap
Tera Contributor

Hi All,

 

I do have scenario when in catalog item there is variable called list collector with country table reference when usa selected puetero Ricco automatically populated.

but i am not able to delete pueteo Ricco  i am able to delete either one if  requires currently its not performing like that.

below scenarios i have followed  can  anyone let me know how to delete either one currently its not performing 

used created one  property where i have added sys_id 's of countries

script include 

sonypaap_0-1692100865238.png

sonypaap_1-1692100907547.png

 

sonypaap_2-1692101157562.png

 

Thanks

 

9 REPLIES 9

@sonypaap is that client script written on list collector(referring country table) field? 

Please share the screenshot of client script(Including table and field name) and script include. Something wrong with configuration

Hi @SANDEEP28 

client script 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
  var gass = new GlideAjax('HRMS_fetchcountrydetails');
    gass.addParam('sysparm_name''getinfodata');
    gass.addParam('sysparm_inc', newValue);
    gass.getXML(callback);

    function callback(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");

        answer = JSON.parse(answer);
        //alert('answer' +answer);
        var america = answer.usa;
        var puetro_rico =  answer.prco;

        var china = answer.chna;
        var result = answer.chna;
        // alert("result"+answer.usa);


        if (newValue == america) {
            
 g_form.setValue('select_the_countries_in_scope', newValue + ',' + puetro_rico);
        }
        
       else if (newValue == china) {
        //     //alert('working2' + answer.chna + ',' + answer.hangsar + ',' + answer.mcrosar);
           g_form.setValue('select_the_countries_in_scope', answer.chna + ',' + answer.hongkongsar + ',' + answer.mcrosar);
        }

        
    }
 
script include
var HRMS_fetchcountrydetails = Class.create();
HRMS_fetchcountrydetails.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

    type: 'HRMS_fetchcountrydetails',
    getinfodata: function() {
        var calling = this.getParameter('sysparm_inc');
        //var str = gs.getProperty('sn_hr_core.getcountrysysid');




        var props = gs.getProperty('sn_hr_sp.getcountrydetails');
        var hashMap = new global.JSON.parse(props); // Add global prefix if in scope
        // var index = 'US';
        // var dabang ='PR';
        // //var chn = "china";
        // var hongsar ="Hong Kong SAR";
        // var macrosar = "Macao SAR";
        var unitedstates = hashMap['US'];
        var rico = hashMap['PR'];
        var chn = hashMap['china'];
        var hongsar = hashMap['HongKongSAR'];
        var macrosar = hashMap['MacaoSAR'];



        var data = {
            usa: unitedstates,
            prco: rico,
            chna: chn,
            hongkongsar: hongsar,
            mcrosar: macrosar
        };
        var data1 = new global.JSON().encode(data);
       // gs.addInfoMessage('data is:'+data1)
        return data1;

    },

@srikriti Which field have you selected on onChange client script ? Have you selected this one "select_the_countries_in_scope" ??

Yes sandeep 

Actually my requirement is when i select USA , puetro rico added into list collector so by end it should be display like this 

sonypaap_0-1692166584970.png

which is working correctly but  i when try to remove puetro rico from list collector its again adding it

so is there any other way the code should be written. if i remove anyone from list collector it should be allow to remove

sonypaap
Tera Contributor

Hi @Ankur Bawiskar can you help me on this scenario if i try to remove puetro rico from list collector its again adding to the list it is not allowing to remove is there any other way need to write the code. hoping  positive response 

 

Thanks