CA Service Management

Expand all | Collapse all

Required CR Fields Only for Select Roles

Jump to Best Answer
  • 1.  Required CR Fields Only for Select Roles

    Posted 09-07-2018 03:19 PM

    We have a custom form for Machine Name and License Key that is only available to two Roles that require that information, other roles can see the ticket just not the fields. We would like to make those two custom fields on the custom forms required for the technicians that see it when opened. Is there a way, via data partition, form mods, custom Request Area etc. to require those two fields only for the two Roles that see it? We don't want it required for others as they won't be able to fill it out if we use the status transition requirement. Any suggestions would be greatly appreciated!



  • 2.  Re: Required CR Fields Only for Select Roles

    Posted 09-08-2018 04:36 AM

    Hi,

    you can modify detail form with role based PDM_IF statement, example:

    <PDM_IF $SESSION.ROLE_ID == 400001 || $SESSION.ROLE_ID == 400002>
        <PDM_MACRO name=dtlTextbox attr=z_somevalue make_required=yes>
    <PDM_ELSE>
        <PDM_MACRO name=dtlReadonly attr=z_somevalue>
    </PDM_IF>

    Where 400001 and 400002 role ids.

    Regards.



  • 3.  Re: Required CR Fields Only for Select Roles

    Posted 09-10-2018 09:35 AM

    Thank you very much for the quick response. I was about to implement in Test and had just had  few questions:

     

    1. With two fields, would both custom fields be in the same statement or do I need a separate statement for each field?

    2. I forgot to mention, and do apologize but not sure it makes a difference, the two custom fields that need to be required can only be seen by the two roles that need it required (on their custom form group); would I need to include these statements in both sets of forms?

    3. Didn't think I needed to but when the statements are added, do I need list these as well under the Status -> Dependent Attributes for Request/Incident?

     

    Thank you,
    Jessie



  • 4.  Re: Required CR Fields Only for Select Roles

    Posted 09-10-2018 09:48 AM

    hi,

    1. there is no limit about code length placed within PDM_IF statement, so you can place both;

    2. code should be on every affilated form;

    3. no other modification needed;

    ps: in my example input provided as editable for 2 roles and readonly for others, to make it visible for roles and hidden for others just remove PDM_ELSE area.



  • 5.  Re: Required CR Fields Only for Select Roles

    Posted 09-10-2018 12:24 PM

    Last question, does it matter where in the code I put the statements above?



  • 6.  Re: Required CR Fields Only for Select Roles

    Posted 09-10-2018 12:31 PM

    just try it in a test env and you'll find an answer



  • 7.  Re: Required CR Fields Only for Select Roles

    Posted 09-10-2018 02:25 PM

    can I also include a Request Area as a condition for the statement?



  • 8.  Re: Required CR Fields Only for Select Roles

    Posted 09-10-2018 02:31 PM

    If you want to make dynamic field that will be changed on the go as category change, you'll need to use some JavaScript logic. But if something static, this one should do the trick:

    <PDM_IF "$args.category" == "pcat:12345">
    </PDM_IF>


  • 9.  Re: Required CR Fields Only for Select Roles

    Posted 09-10-2018 03:23 PM

    Here is the syntax for 2 x Roles and 2 x PCAT areas identified as needing the custom fields required, does this look right?

    <PDM_IF $SESSION.ROLE_ID == 400001 || $SESSION.ROLE_ID == 400151 && "$args.category" == "pcat:400054">
        <PDM_MACRO name=dtlTextbox attr=zz_PCName make_required=yes>
    <PDM_ELSE>
        <PDM_MACRO name=dtlReadonly attr=zz_PCName>
    </PDM_IF>

    <PDM_IF $SESSION.ROLE_ID == 400001 || $SESSION.ROLE_ID == 400151 && "$args.category" == "pcat:400055">
        <PDM_MACRO name=dtlTextbox attr=zz_PCName make_required=yes>
    <PDM_ELSE>
        <PDM_MACRO name=dtlReadonly attr=zz_PCName>
    </PDM_IF>

    <PDM_IF $SESSION.ROLE_ID == 400303 || $SESSION.ROLE_ID == 400303 && "$args.category" == "pcat:400054">
        <PDM_MACRO name=dtlTextbox attr=zz_PCName make_required=yes>
    <PDM_ELSE>
        <PDM_MACRO name=dtlReadonly attr=zz_PCName>
    </PDM_IF>

    <PDM_IF $SESSION.ROLE_ID == 400303 || $SESSION.ROLE_ID == 400303 && "$args.category" == "pcat:400055">
        <PDM_MACRO name=dtlTextbox attr=zz_PCName make_required=yes>
    <PDM_ELSE>
        <PDM_MACRO name=dtlReadonly attr=zz_PCName>
    </PDM_IF>



  • 10.  Re: Required CR Fields Only for Select Roles

    Posted 09-10-2018 04:15 PM

    You can try to use brackets to combine statements but as far as i know only one type of statement (AND or OR) can be used within one pdm_if tag:

     

    <PDM_IF "$args.category" == "pcat:400055" || "$args.category" == "pcat:400054">
         <PDM_IF $SESSION.ROLE_ID == 400001 || $SESSION.ROLE_ID == 400151 || $SESSION.ROLE_ID == 400303>
              <PDM_MACRO name=dtlTextbox attr=zz_PCName make_required=yes>
         <PDM_ELSE>
              <PDM_MACRO name=dtlReadonly attr=zz_PCName>
         </PDM_IF>
    <PDM_ELSE>
         <PDM_MACRO name=dtlReadonly attr=zz_PCName>
    </PDM_IF>


  • 11.  Re: Required CR Fields Only for Select Roles

    Posted 09-11-2018 01:34 PM

    I do apologize for all the follow-up questions. Is there a limit to how many Request Areas can be included in the code? I am now looking at over 20. Maybe a wildcard since they all fall under the schema:

    Hardware>Workstation>""

    Hardware>Laptop>""

    Software>Desktop Application>""

     

    I don't want there to be performance issues.



  • 12.  Re: Required CR Fields Only for Select Roles

    Posted 09-11-2018 01:44 PM

    i prefer to publish new flags for situations like this:

    <PDM_IF "$args.category.z_limit_view" == "2">
         // some data here
    <PDM_ELIF  "$args.category.z_limit_view" == "1">
         // another data here
    <PDM_ELSE>
         // default output here
    </PDM_IF>

    so you can easily maintain categories using interface.

     

    Also you can check this one: Implementation Guide Release 12.9.00 something like this should work:

    <PDM_IF "$args.category.sym" : "Hardware." || "$args.category.sym" : "Software.">


  • 13.  Re: Required CR Fields Only for Select Roles

    Posted 09-13-2018 10:36 AM

    Last question, promise. I was unable to get the link you sent to resolve to the user guide, Is there a wildcard that I can use after the category such as an "*"?

     "Hardware.Workstation.*"



  • 14.  Re: Required CR Fields Only for Select Roles

    Posted 09-13-2018 10:52 AM

    the right side is regexp, so condition could be something like "Hardware\.Workstation\..+"

    if this won't work you can always use regular javascript:

    if ("$args.category.sym".indexOf("Hardware.Workstation.") >= 0) {


  • 15.  Re: Required CR Fields Only for Select Roles

    Posted 09-18-2018 10:58 AM

    Thank you again cdtj; I am struggling with the syntax. I tried:

    <PDM_IF "$args.category.sym" : "Hardware\.Workstation\.Desktop\.+" || "$args.category.sym" : "Hardware\.Workstation\.Laptop\.+">
    <PDM_IF $SESSION.ROLE_ID == 400001 || $SESSION.ROLE_ID == 400151 || $SESSION.ROLE_ID == 400303>
    <PDM_MACRO name=dtlTextbox attr=zz_PCName make_required=yes>
    <PDM_ELSE>
    <PDM_MACRO name=dtlReadonly attr=zz_PCName>
    </PDM_IF>

     

    But was unable to make it work so was going to use the straight java route. However, I am not sure how I would do 20+ areas, would it be a function like what is in the detail_in?

     

    function copy_from_cr()
    {
        if ("$args.KEEP.MAKE_COPY" == "1")
        {
     var exceptions = new Array();
     exceptions[0] = "SET.customer";
        exceptions[0] = "SET.requested_by";
     detailCopyEditForm(exceptions);
        }
    }

    Thank you again,

    Jessie



  • 16.  Re: Required CR Fields Only for Select Roles

    Broadcom Employee
    Posted 09-19-2018 01:27 PM

    cdtj can you provide jlhawley with additional assistance on your proposed solution?



  • 17.  Re: Required CR Fields Only for Select Roles
    Best Answer

    Posted 09-19-2018 01:31 PM

    Missed that, jlhawley, as I suggested before, best way is to publish new attribute and use it to hide unwanted categories. WSP guide: How to Modify Schema Using Web Screen Painter - CA Service Management - 14.1 - CA Technologies Documentation 



  • 18.  Re: Required CR Fields Only for Select Roles

    Broadcom Employee
    Posted 09-18-2018 10:43 AM

    jlhawley 

    Do you require any additional assistance on this topic?

     

    If not, please mark one of the provided responses as correct so that this thread can be closed.