Catalog item- How to call values in Drop down variable via system property

Kamini07
Tera Contributor

Hello Experts,

 

I have got a use case scenario where we required to populate values in a drop down variable in a catalog item. And those values should be coming via system property. Field is depended on another drop down. 

 

Thanks in advance

3 REPLIES 3

KeerthiP
Mega Guru

Hi,

 

Please try the below steps.

 

1. Create System Properties: Define a system property with the values for the dropdown.
2. Create a Script Include: Write a Script Include to fetch the values from the system property.
3. Create a Catalog Client Script: Create a Client Script that triggers on change of the primary dropdown and populates the dependent dropdown with values fetched from the Script Include.
4. Configure Catalog Item Variables: Ensure you have two dropdown variables in your catalog item - one primary and one dependent.

Thanks,

Keerthi

Ankur Bawiskar
Tera Patron
Tera Patron

@Kamini07 

why to have system property? choices needs to be there in choices table

what's the business requirement for this?

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

GopikaP
Mega Sage

Hi @Kamini07 , It is not possible with multiple choice, instead choose Select Box, then

In the onLoad catalog client script - 

var ga = new GlideAjax('ClientSideCall');
    ga.addParam('sysparm_name', 'getProperty');
    ga.getXML(getP);

    function getP(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        var arr = answer.split(',');
        for (var i = 0; i < arr.length; i++) {
            g_form.addOption('drop_down', i, arr[i], i);
        }
    }

In the Glide AJAX enabled script Include - 

var ClientSideCall = Class.create();
ClientSideCall.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	getProperty:function(){
		return gs.getProperty('drop.down.sys.property');
	},
    type: 'ClientSideCall'
});