catalog item form design

Murali Reddy
Tera Contributor

I am working on Catalog item form designing part of that Role type and Role name two variables are created. in Role type variables are having jar1, jar2 options are having , in Role Name variable having the options Mug1,mug2,mug3,mug4,mug5,mug6.

suppose if select the jar1 option in Role type filed then Role Name variable will shown mug1,mug2,mug3

suppose if i select the jar2 option in role type field then role name field will shown mug4,mug5,mug6

suppose if i select the jar1,jar2, at the same time in Role Type field then Role Name field will shown mug1,mug2,mug3,mug4,mug5,mug6

how to achieve this one?

2 ACCEPTED SOLUTIONS

Hello @Murali Reddy 

I have the solution to your question. Please follow the following process.

1. Role Type: List Collector

  •  Create two choices in Question Choice table
    • Jar1 and Jar2
  • Set the reference qualifier to the variable like below
    • question=3b050ddb83d8a21038cfc7e0deaad309 //sys_id of your role type variable

2. Role Name: List Collector

  • Create 6 choices in Question Choice table
    • Mug1,mug2,mug3,mug4,mug5,mug6
  • Set the reference qualifier to the variable like below
    • question=cf95011f83d8a21038cfc7e0deaad3bc   //sys_id of your role name variable

3. Create a custom field in Question Choice

  • Type: Reference
  • Reference Table: Question Choice
  • Label: Dependant Value

4. Set the dependent value in the question choice table like below

RushiSavarkar_3-1742553482858.png

 

5. Create a client callable script include

var ADAPICall = Class.create();
ADAPICall.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getRoles: function() {
		var rolenames = [];
        var roleType = this.getParameter('sysparm_type');
        var gr = new GlideRecord('question_choice');
		gr.addQuery("question", "place_your_question_sys_id"); // Role Name question sys_id
		gr.addEncodedQuery("u_dependant_value.sys_idIN" + roleType);
        gr.query();
        while (gr.next()) {
           rolenames.push(gr.sys_id.toString());
        }
        return rolenames.join(',');
    },

    type: 'ADAPICall'
});

6. Create OnChange Catalog Client script on Role Type variable

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
		g_form.clearValue("role_name");
        return;
    }
    var roleType = g_form.getValue('role_type');
    var getRoleNames = new GlideAjax('ADAPICall');
    getRoleNames.addParam('sysparm_name', 'getRoles');
    getRoleNames.addParam('sysparm_type', roleType);
    getRoleNames.getXML(callBack);

    function callBack(response) {
        var answer = response.responseXML.documentElement.getAttribute('answer');
        alert(answer);
            g_form.setValue('role_name', answer);
    }

 Output: 

1. 

RushiSavarkar_0-1742553287174.png

2. 

RushiSavarkar_1-1742553324653.png

3. 

RushiSavarkar_2-1742553350777.png

 

If my response helped you, please accept the solution and mark it as helpful.
Thank You!

View solution in original post

Hello @Murali Reddy 

Have you tried the solution mentioned above?

If my response helped you, please accept the solution and mark it as helpful.
Thank You!

View solution in original post

9 REPLIES 9

Rushi Savarkar
Kilo Sage

Hello @Murali Reddy 

I will have the answer to your question tomorrow. As I worked on a similar requirement, basically there is no straightforward approach to meet this requirement. We need to do some customization to the OOB table that is Question Choice and then only we can achieve this.

If my response helped you, please accept the solution and mark it as helpful.
Thank You!

Murali Reddy
Tera Contributor

thanks for responding Rushi. I will try my end also .Suppose if i got then i will let you kow

Hello @Murali Reddy 

I have the solution to your question. Please follow the following process.

1. Role Type: List Collector

  •  Create two choices in Question Choice table
    • Jar1 and Jar2
  • Set the reference qualifier to the variable like below
    • question=3b050ddb83d8a21038cfc7e0deaad309 //sys_id of your role type variable

2. Role Name: List Collector

  • Create 6 choices in Question Choice table
    • Mug1,mug2,mug3,mug4,mug5,mug6
  • Set the reference qualifier to the variable like below
    • question=cf95011f83d8a21038cfc7e0deaad3bc   //sys_id of your role name variable

3. Create a custom field in Question Choice

  • Type: Reference
  • Reference Table: Question Choice
  • Label: Dependant Value

4. Set the dependent value in the question choice table like below

RushiSavarkar_3-1742553482858.png

 

5. Create a client callable script include

var ADAPICall = Class.create();
ADAPICall.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getRoles: function() {
		var rolenames = [];
        var roleType = this.getParameter('sysparm_type');
        var gr = new GlideRecord('question_choice');
		gr.addQuery("question", "place_your_question_sys_id"); // Role Name question sys_id
		gr.addEncodedQuery("u_dependant_value.sys_idIN" + roleType);
        gr.query();
        while (gr.next()) {
           rolenames.push(gr.sys_id.toString());
        }
        return rolenames.join(',');
    },

    type: 'ADAPICall'
});

6. Create OnChange Catalog Client script on Role Type variable

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
		g_form.clearValue("role_name");
        return;
    }
    var roleType = g_form.getValue('role_type');
    var getRoleNames = new GlideAjax('ADAPICall');
    getRoleNames.addParam('sysparm_name', 'getRoles');
    getRoleNames.addParam('sysparm_type', roleType);
    getRoleNames.getXML(callBack);

    function callBack(response) {
        var answer = response.responseXML.documentElement.getAttribute('answer');
        alert(answer);
            g_form.setValue('role_name', answer);
    }

 Output: 

1. 

RushiSavarkar_0-1742553287174.png

2. 

RushiSavarkar_1-1742553324653.png

3. 

RushiSavarkar_2-1742553350777.png

 

If my response helped you, please accept the solution and mark it as helpful.
Thank You!

Hello @Murali Reddy 

Have you tried the solution mentioned above?

If my response helped you, please accept the solution and mark it as helpful.
Thank You!