Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Get a variable value (Multiple Choice) - Client Script / Script Includes

MysUser
Tera Contributor

Hello! I want to get a question_choice (from the Multiple Choice) checked by the user on Catalog Item. I'm using Order Guide, so I have to pick this value from each card. I created a script on the Client side, that connect with the server using Ajax:

var ga = new GlideAjax('checkAttachments');
    var cart = $j('#sysparm_cart_edit').val();
    ga.addParam('sysparm_name', 'checknumber');
    ga.addParam('sysparm_cart_id', cart);
    ga.addParam('sysparm_attach_number', 1);
    ga.getXMLWait();

Script on the Server Side below:

var cart = new GlideRecord('sc_cart_item');
cart.addQuery('sys_id', this.getParameter('sysparm_cart_id'));
cart.query();
    
while(cart.next()) {
            var attachment = new GlideRecord('sys_attachment');
            attachment.addQuery('table_name', 'sc_cart_item');
            attachment.addQuery('table_sys_id', cart.sys_id.toString());
            attachment.query();
           
            
            var value = cart.variables.AAA;

 

By this end value I'm getting the question choice pinned to the multiple choice called AAA - but I would like to get the value the user has selected. Do you have any ideas how to solve this issue?

1 ACCEPTED SOLUTION

Swathi12
Tera Expert

If you want to get the variable value set by user :

script include : current.variables.yourvariablename

catalog client script : g_form.getValue('yourvariablename') 

 

Please do mark this answer helpful/correct if it answered your question.

 

Regards,

Swathi

View solution in original post

1 REPLY 1

Swathi12
Tera Expert

If you want to get the variable value set by user :

script include : current.variables.yourvariablename

catalog client script : g_form.getValue('yourvariablename') 

 

Please do mark this answer helpful/correct if it answered your question.

 

Regards,

Swathi