Show specific ci class in change request upon selecting a specific category

saptarshiamc
Tera Contributor

In the process of creating a new change request for a selection of specific categories (for example: selecting "ABC" category) the user wants to see only a specific class of resources (Server - cmdb_ci_server) instead of all CIs and for other categories want to see all the ci

1 ACCEPTED SOLUTION

Amit Gujarathi
Giga Sage
Giga Sage

HI @saptarshiamc ,
I trust you are doing great.

Create a Business Rule:

  • Navigate to "System Definition" > "Business Rules" in the ServiceNow application.

  • Click on "New" to create a new Business Rule.

  • Provide a suitable name and description for the Business Rule.

  • Set the "Table" field to "change_request" to target the change request table.

  • In the "Advanced" section, enter the following code:

(function executeRule(current, previous /*null when async*/) {
    if (current.category == "ABC") {
        current.cmdb_ci = "cmdb_ci_server";
    } else {
        current.cmdb_ci = "";
    }
})(current, previous);
    • Save the Business Rule.

  1. Modify the Change Request form:

    • Navigate to "System Applications" > "Customize Form" in the ServiceNow application.

    • Search for and open the "Change Request" form.

    • Edit the form layout.

    • Locate the "Configuration item" field.

    • In the "Default Value" section of the field properties, enter the following code:

javascript:if(g_form.getValue('category') == 'ABC') { 'cmdb_ci_server'; } else { ''; }

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post

1 REPLY 1

Amit Gujarathi
Giga Sage
Giga Sage

HI @saptarshiamc ,
I trust you are doing great.

Create a Business Rule:

  • Navigate to "System Definition" > "Business Rules" in the ServiceNow application.

  • Click on "New" to create a new Business Rule.

  • Provide a suitable name and description for the Business Rule.

  • Set the "Table" field to "change_request" to target the change request table.

  • In the "Advanced" section, enter the following code:

(function executeRule(current, previous /*null when async*/) {
    if (current.category == "ABC") {
        current.cmdb_ci = "cmdb_ci_server";
    } else {
        current.cmdb_ci = "";
    }
})(current, previous);
    • Save the Business Rule.

  1. Modify the Change Request form:

    • Navigate to "System Applications" > "Customize Form" in the ServiceNow application.

    • Search for and open the "Change Request" form.

    • Edit the form layout.

    • Locate the "Configuration item" field.

    • In the "Default Value" section of the field properties, enter the following code:

javascript:if(g_form.getValue('category') == 'ABC') { 'cmdb_ci_server'; } else { ''; }

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi