We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to create catalog item specific states on SCTASK form

Not applicable

Hello There,

 

Greetings!!!

 

We have a requirement to create or add some states on SCTASK form for specific catalog items. Your help is highly appreciated.

 

Thanks,

Tejas

4 REPLIES 4

Satishkumar B
Giga Sage

@Community Alums To manage custom states on the SCTASK form for specific catalog items, define the states, use Client Script/UI Policy for visibility and functionality.

…………………………………………........................................................................................
Please Mark it helpful 👍and Accept Solution !! If this helps you to understand.

…………………………………………........................................................................................

Not applicable

Hello @Satishkumar B ,

 

Thank you for your reply. I am aware that we need to achieve that using client script/ui policy, I tried addoption or removeoption methods but it's not working, do you have any working script or solution.

 

Thanks,

Tejas

@Community Alums try this , it worked for me:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
   var catalogItemStates = {
        'implementation': ['1', '2'],
        'testing': ['3', '4']
    };

    // Get the current change task type (newValue)
    var catalogItem = newValue;

    // Get the states for the current change task type
    var validStates = catalogItemStates[catalogItem] || [];

    // Clear existing state options
    g_form.clearOptions('state');

    // Add valid state options
    validStates.forEach(function(state) {
        g_form.addOption('state', state, state);
    });
   
}

 

 

…………………………………………........................................................................................
Please Mark it helpful 👍and Accept Solution !! If this helps you to understand.

…………………………………………........................................................................................

WayneH490346913
Tera Contributor

Hi @Community Alums 

I have this same requirement. I'm not seeing that the solution suggested by @Satishkumar B worked for you, did you try it or find another solution? Thank you.