How to show values of String in the select box.

Samiksha2
Mega Sage

Hi All,

 

I have a requirement to show the string values in the select box.

Samiksha2_0-1706366674755.png

This CSMText field is in account table and these values should be populate in the Catalog item as select box.

Please help in this.

 

Thanks,

Sam

1 ACCEPTED SOLUTION

Hi @Dr Atul G- LNG ,

I have done that.

I have written a script include and Onload cline script

Script Include
getCMS: function() {
        var answer = [];
        var users = this.getParameter('user');
        var grs = new GlideRecord('customer_account');
        grs.addEncodedQuery('customer=true^sys_id=' + users);
        grs.query();
        while (grs.next()) {
            answer.push(grs.u_csmtext.toString());
        }
        return answer.join(',');
    },

Client Script
   var tes = g_form.getValue("u_account");
    var gsr = new GlideAjax('get_csm');
    gsr.addParam('sysparm_name', 'getCSM');
    gsr.addParam('user', tes);
    gsr.getXML(test);

    function test(response) {
        var answers= response.responseXML.documentElement.getAttribute('answer');
        var array = answers.split(',');
        for (var i = 0; i < array.length; i++) {
            g_form.addOption('csm', array[i], array[i]);
        }
    }

 

 

View solution in original post

7 REPLIES 7

Hi @Samiksha2 

 

really sorry, but I am not this much expert in SN.

 

https://www.servicenow.com/community/developer-forum/value-from-lookup-select-box-copied-to-string/m...

 

@Anurag Tripathi @Jaspal Singh  @SanjivMeher 

 

any thoughts.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG ,

I tried but it is showing like this

Samiksha2_0-1706388547396.png

 

Hi @Dr Atul G- LNG ,

I have done that.

I have written a script include and Onload cline script

Script Include
getCMS: function() {
        var answer = [];
        var users = this.getParameter('user');
        var grs = new GlideRecord('customer_account');
        grs.addEncodedQuery('customer=true^sys_id=' + users);
        grs.query();
        while (grs.next()) {
            answer.push(grs.u_csmtext.toString());
        }
        return answer.join(',');
    },

Client Script
   var tes = g_form.getValue("u_account");
    var gsr = new GlideAjax('get_csm');
    gsr.addParam('sysparm_name', 'getCSM');
    gsr.addParam('user', tes);
    gsr.getXML(test);

    function test(response) {
        var answers= response.responseXML.documentElement.getAttribute('answer');
        var array = answers.split(',');
        for (var i = 0; i < array.length; i++) {
            g_form.addOption('csm', array[i], array[i]);
        }
    }