CA Service Management

  • 1.  Custom fields conditionally required

    Posted Nov 16, 2018 12:49 AM

    Dear All,

     

    We have CA SDM 12.9 in our production environment.. We have requirement - Custom fields in detail_in.htmpl form should be made mandate when incident area is "xyz" and status is closed. How to achieve this 



  • 2.  Re: Custom fields conditionally required

    Broadcom Employee
    Posted Nov 16, 2018 12:19 PM

    you could use preSaveTrigger2(). take a look at

    PreSaveTrigger - Type and Rootcause 



  • 3.  Re: Custom fields conditionally required

    Posted Nov 20, 2018 12:31 AM

    Hi,

     

    I am using, below spel code, but it is not working as expected.

     

    cr::zmyscript(...)
    {
    string zmsg;
    if(is_null("affected_rc"))
    {
    zmsg=format("Configuration Item is required in order to close this incident");
    set_error(1);
    set_return_data(zmsg);
    }
    return;
    }



  • 4.  Re: Custom fields conditionally required

    Posted Nov 20, 2018 02:41 AM

    I take it you are calling this from an ON_PRE_VALIDATE trigger?

     

    I suggest you consider the following:

    1. The affected resource field is 'affected_resource', not 'affected_rc'.  Use 'bop_sinfo -d <object>' to display the field names in the object layer for use in spel, as the output from 'pdm_extract' shows the names in the schema layer which are not always the same.

    2. Use 'is_null(affected_resource)' or 'is_null(this.affected_resource)', to test the value of the field.  Putting double quotes round the label turns it into a string, so you're currently testing 'is the string "affected_rc" null?' - which it will never be.

    3. No need to use 'format' to set the string into 'zmsg'. This would do:

    zmsg = "Configuration Item is required in order to close this incident";

     

    Hope that helps!  Please let me know how you go.

    Regards,

    James



  • 5.  Re: Custom fields conditionally required

    Posted Nov 20, 2018 04:37 AM

    Hi James,

     

    yes i am using pre_validate trigger in cr object

     

    PRE_VALIDATE zmyscript() 111 FILTER(active==0);

     

    Now i corrected the spel, now the ticket is getting closed with or without CI.

     

    cr::zmyscript(...)
    {
    string zmsg;
    if ('is_null(affected_resource)')
    {
    zmsg="Configuration Item is required in order to close this incident";
    set_error(1);
    set_return_data(zmsg);
    return;
    }
    }



  • 6.  Re: Custom fields conditionally required

    Posted Nov 20, 2018 05:59 AM

    Hi James,

     

    Will this one works in SDM 17.1 version ?..



  • 7.  Re: Custom fields conditionally required
    Best Answer

    Posted Nov 20, 2018 07:43 AM

    You don’t need single quotes here, try removing them as it might be treating this as a string and not an attribute.

     

    if ('is_null(affected_resource)')



  • 8.  Re: Custom fields conditionally required

    Posted Nov 20, 2018 08:52 AM

    Hi Grant,

     

    Thanks.. It works perfectly..

     

    spl code

     

    cr::zmyscript(...)
    {
    string zmsg;
    if (priority == 4 || priority == 5)
    {
    if (is_null(affected_resource))
    {
    zmsg="Configuration Item is required in order to close this incident";
    set_error(1);
    set_return_data(zmsg);
    return;
    }
    }
    }

     

    Trigger

     

    PRE_VALIDATE zmyscript() 111 FILTER(active==0);

     

    Thanks James & grant for your support..



  • 9.  Re: Custom fields conditionally required

    Posted Nov 20, 2018 09:19 PM

    Glad you got it working.  You are most welcome.