CA Service Management

 View Only
  • 1.  Hide/Disable an entire Form using JavaScript Expressions

    Posted May 18, 2014 09:04 PM

    You have the option to hide or disable an entire form by using JavaScript Expressions, within a service option click on the attached form.

    The form definition box will appear and you will see Disable and Hidden fields, which you can add JavaScript expressions to return true/false based on object properties.

    See Page 350 of SC 12.9 Admin Guide.

    Examples follow:
    ■ To hide or disable the form when the request status is Pending Approval, enter
    the following JavaScript expression in the Hidden or Disabled field:
    $(_.request.status == 400).
    ■ To hide or disable the form for end user roles only, enter $(_.user.role ==
    ‘enduser’).
    ■ To hide or disable the form from all business units except ca.com, enter
    $(_.bu.id != ‘ca.com’).
    ■ To disable the form when the request status is Fulfilled, enter
    $(_.request.status == 2000). 

    I want to know how can you hide a form based on the group a user might be part of. When using firebug console in firefox and calling user.groups it returns all the groups within an array.

    How would you check for a group in a javascript expression without somehow looping through each array item to check?



  • 2.  RE: Hide/Disable an entire Form using JavaScript Expressions
    Best Answer

    Posted May 21, 2014 08:53 PM
    paulstecca:

    I want to know how can you hide a form based on the group a user might be part of. When using firebug console in firefox and calling user.groups it returns all the groups within an array.

    To deny a user who is a member of group abc use the following expression:

    $(_.user.groups.indexOf("abc") >= 0 ) or

    $(_.user.groups.IndexOf("abc") > -1)