Need to Customize DropDown Menu

rah dev
Tera Contributor

There is need to customize drop down in UI Builder, when incident selected, there should be form of incident record and if second option selected, there other table should show.

rahdev_1-1713810834836.png

 

1 ACCEPTED SOLUTION

IbrarA
Giga Guru

@rah dev you can implement following steps:

 

create client script and  use this code:

/**

 * @param {params} params

 * @param {api} params.api

 * @param {any} params.event

 * @param {any} params.imports

 */

function handler({

    api,

    event,

    helpers,

    imports

}) {

    var table;

    switch(event.payload.item.id){

         case "incident":

        {   table = "incident";

            break;}

        case "change request":

        {   table = "change_request";

            break;}

       

    }

    api.emit('NAV_ITEM_SELECTED', {

        route: "record",

        fields: {

            table: table,

            sysId: "-1"

        }

    });

}

IbrarA_0-1713899262505.png

 

Create client state:

IbrarA_1-1713899262511.png

 

 

Add your above client script on dropdown events:

IbrarA_2-1713899262517.png

 

ibrar

View solution in original post

6 REPLIES 6

Have you looked at that particular component of the Compliance Workspace in the UI Builder?

 

Looks like a Dropdown component, you can find the configuration details in the documentation - https://developer.servicenow.com/dev.do#!/reference/next-experience/washingtondc/now-components/now-...

IbrarA
Giga Guru

@rah dev you can implement following steps:

 

create client script and  use this code:

/**

 * @param {params} params

 * @param {api} params.api

 * @param {any} params.event

 * @param {any} params.imports

 */

function handler({

    api,

    event,

    helpers,

    imports

}) {

    var table;

    switch(event.payload.item.id){

         case "incident":

        {   table = "incident";

            break;}

        case "change request":

        {   table = "change_request";

            break;}

       

    }

    api.emit('NAV_ITEM_SELECTED', {

        route: "record",

        fields: {

            table: table,

            sysId: "-1"

        }

    });

}

IbrarA_0-1713899262505.png

 

Create client state:

IbrarA_1-1713899262511.png

 

 

Add your above client script on dropdown events:

IbrarA_2-1713899262517.png

 

ibrar