How to hide the field(Install status) from the respective class like (cmdb_ci_server) on change form

raj99918
Tera Contributor

Hi

 

I have requirement like on change request form having CI class field which contains classes like cmdb_ci_server,cmdb_ci,netgear,cmdb_ci_business_app and we have one more field name called Change lookup this field contains all the fields of the respective classes for example if you select  CI class name as cmdb_ci_server then in the change lookup will contains all the fields of the class cmdb_ci_server so now I want to hide one field(Install status) from that change lookup when user selects the CI class as cmdb_ci_server. How can I build this functionality for your refernce am attching the screenshot for the same.

 

cmdb.jpg

Need to hide that red colour one Install status from that change lookup field when the select the CI class as cmdb_ci_server.

 

14 REPLIES 14

swapnali ombale
Kilo Sage

Hi @raj99918 

 

You need to create before query business rule for this requirement.

 

  1. 1. Create a before query  Business Rule:
    • Navigate to the system defination >business rule.

     

    • Click "New" to create a new Business Rule.
    • Set the table to "Change Task" (or the specific table where you're seeing the lookup field).
    • Select "befoe query" for the action type.
    • Set the "When" condition to "t
  2. 2. Add the business rule script:
    (function executeRule(current, previous) {
    if (current.u_ci_class.getLabel() == 'cmdb_ci_server' && current.u_ci_class != null) {
    current.u_ci_install_status.setValue(-1); // -1 is a default value to hide the option
    }
    })(current, previous);
     
    Click submit and test 
     
    Kindly mark my answer as helpful and accept solution if it helped you in anyway. 

Hi @swapnali ombale  Sorry I tried above code but still no luck

 

Thanks

Ankur Bawiskar
Tera Patron
Tera Patron

@raj99918 

I couldn't find these 2 fields on CHG form

Seems those are custom one?

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

Yes @Ankur Bawiskar  Those are custom fields.

 

Thanks