How do I show state choice "closed skipped" on sc_task table ONLY for 1 c item and hide for others?

cicgordy
Tera Guru

How do I show the state choice "closed skipped" on sc_task table ONLY for one catalog item in particular called "hardware request" and hide all the others ? I don't want other catalog items to have this state choice.

 

cicgordy_0-1677003460165.png

I have tried UI policy with a condition "item is "hardware" but I am struggling with script. Any help with script or any other way to achieve this? 

 

Any help will be appreciated, thanks.

1 ACCEPTED SOLUTION

@cicgordy ,

 

This is a tried and tested solution in my PDI and it works for me perfectly fine... check my attached solution which I have tested in my PDI. Might be you are missing something. Make sure that what is the backend value of "close skipped" in your instance.

PRINCE_ARORA_0-1677163990868.png


If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

View solution in original post

14 REPLIES 14

hi @Prince Arora 

 

"Hardware approval" is the short description. 

"Hardware request" is the name of the catalog item.

I want the "close skipped" state choice to appear/show ONLY when catalog task "Hardware approval" creates (therefore only for "Hardware request" item on that particular task)

@cicgordy ,

Please write a on load script on the "sc_task" table as mentioned below:


function onLoad() {
g_form.getReference('request_item',Myfunc);
function Myfunc(response){
if(g_form.getValue('short_description') != "Hardware approval" && (response.cat_item).getDisplayValue() != "Hardware request"){
g_form.removeOption('state',7);
}
}
}


Could you please try this and let me know if it works for you!

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact!

Thanks for this, but not working sadly

@cicgordy ,

Can you try this, I believe getDisplayValue is not working in client side, can you just change the logic as mentioned below
instead of name of the catalog item just update the sys_id of the catalog item and try it once if it works or not!
( && response.cat_item + "" != "SYS_ID_OF_CAT_ITEM")

 

function onLoad() {
g_form.getReference('request_item',Myfunc);
function Myfunc(response){
if(g_form.getValue('short_description') != "Hardware approval" && response.cat_item + "" != "SYS_ID_OF_CAT_ITEM"){
g_form.removeOption('state',7);
}
}
}

 Please try this and let me know if it works!

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

nothing, it doesnt work! so frustrating