Hi Team, I have created a field in the sc_task called "Item in good condition?"

AA6
Tera Contributor

Hi Team,

I have created a field in the sc_task called "Item in good condition?". However, when the RITM state is deployment prep, the "Item in good condition?" field needs to be visible for a specific catalog task.

Please help me.

2 REPLIES 2

Rohit  Singh
Mega Sage

Hi @AA6 ,

 

You can write On Load Client Script and Client Callable Script Include.

 

  1. Find the identifier in Catalog task for which you want to change the behaviour of your field ("Item in good condition",true). Then put the condition in if Condition -> If it is true then write below code inside the condition.
  2. In On Load Client script you can send the value of RITM field to script include.
  3. Now in script include do a glide record in RITM table.
  4. In addquery gr.addQuey("Number",this,getParameter("ritm_num"));
  5. if RITM state = deployment prep then return true else return false.
  6. In client script if response is true then g_form.setVisible("Item in good condition",true) else g_form.setVisible("Item in good condition",false)

If my response helped, please hit the Thumb Icon and accept the solution so that it benefits future readers.

 

Regards,
Rohit

Ankur Bawiskar
Tera Patron
Tera Patron

@AA6 

Did you create a new state value on RITM for that?

if yes then you can use onLoad client script on sc_task and display business rule on sc_task for that

Display Business rule:

(function executeRule(current, previous /*null when async*/) {
    // Initialize g_scratchpad
    g_scratchpad.showItemConditionField = 'false';

    // Check if the RITM state is 'deployment_prep' ensure you give correct choice value to compare
    if (current.request_item.state == 'deployment_prep' && current.short_description == 'Your Specific Task Short Description') {
        g_scratchpad.showItemConditionField = 'true';
    }
})(current, previous);

onLoad client script:

function onLoad(){
    // Check the value of g_scratchpad.showItemConditionField
    if (g_scratchpad.showItemConditionField == 'true') {
        // Make the 'Item in good condition?' field visible
        g_form.setDisplay('item_in_good_condition', true);
    } else {
        // Hide the 'Item in good condition?' field
        g_form.setDisplay('item_in_good_condition', false);
    }
}

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