Need to display the variable in catalog form

suuriyas
Tera Contributor

HI Community,

 

I have a requirement, in catalog form we have a variable called software (reference to software install table) and price variable (single line). in software install table there is field called Licence Type 

When user selects any software in software variable and its licence type is licensed then show the price variable in form if not do not show this.

Please provide me the catalog client script and script include.

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@suuriyas 

you cannot do this with UI policy.

You will have to use onChange client script with getReference callback and check the type and then show/hide the other variable

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) {
        return;
    }

    var ref = g_form.getReference('softwareVariable', callBackMethod); // software variable name
}

function callBackMethod(ref) {
	// compare correct field name and choice value for licensed
    if (ref.licenseTypeField == 'licensed')
        g_form.setDisplay('otherVariable', true); // give other variable name here
    else
        g_form.setDisplay('otherVariable', false); // give other variable name here
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

@suuriyas 

it must be because of some other client script or UI policy.

Did you debug that?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@suuriyas 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader