Setting the visibility of coach views

To allow or prevent users from seeing or editing a coach view, set its visibility property.

About this task

By default, coach views are visible and editable. However, you can change the following options on the Visibility page of the coach view.
  • Editable
  • Required
  • Read only
  • Hidden
  • None

Additionally, you can set the coach view to inherit its visibility from the coach or coach view that contains it. You do this by setting the visibility of the your coach view to Same as parent. For example, your coach view is within a coach view that has Read only visibility. If your coach view is set to Same as parent visibility, your coach view inherits the Read only value. Same as parent is the default value. For information about these options and visibility in general, see Coach view visibility properties.

The contents of the Visibility page differs depending on whether the coach view is within a coach or a coach view.
Within a coach Within a coach view
For a coach view that is in the layout of a coach, you can set the visibility of the coach view according to a value, rule, or script.
Visibility page with three source options: value, rule, and script. Value is selected and the page shows the user interface for setting the visibility according to a value.

Generally, setting the visibility by value is the simplest but least flexible option while setting the visibility by script is the most complex but most flexible option.

You can also change the visibility according to the screen size if you chose to set visibility by value. For example, you might want to have a coach view visible in a large screen but hide it for a medium or small screen. To do this, you would set the visibility to Editable when you are editing the large screen layout. You then switch to the medium screen layout and change the visibility to Hidden or None. If you do not specify a value for the small screen layout, it inherits the visibility value from the medium screen layout. For information, see Responsive settings for coach views.
Restriction: You cannot have different rules or scripts for each screen size setting.
For a coach view that is in the layout of a coach view, you can set the visibility of the coach view according only to a value.
Visibility page that shows the user interface for setting the visibility according to a value

In the procedure, only the first option applies.

Procedure

In the Visibility properties of a coach view, set its visibility in one of the following ways:
By value
Select Value and then either select a value from the list or click Assign a variable, and then select the variable that determines the visibility of the coach view. You can optionally set a different value for different screen size settings by selecting the screen size setting first, then selecting the visibility value for that screen size setting.
Note: If you set the visibility of a view to Hidden or None, it does not display on the canvas. If you want to set the properties of a hidden view, first select the view in the Invisible Items section of the palette, then configure the view properties.
By rule
Select Rule and then create a visibility rule set. A visibility rule set has one or more rules and a default value for when no rule applies. The rules have an OR relationship. Place the rules in the order of their applicability because the coach view uses the visibility value of the first rule that applies.
  1. Determine whether the first rule in the rule set is based on a variable value or on a team membership and select Variable or Team accordingly.
  2. Set the default value for the rule set by selecting a value in the Otherwise field.
  3. Create the first rule in the rule set.
    For a variable, the format of the rule is visibility variable condition value. To create a visibility rule that is based on a variable value, complete the following steps:
    • For visibility, set the value for the visibility in the Set to field.
    • For variable, click Select and then select the variable that is defined in the human service that determines when the visibility value applies.
    • For condition, select the type of comparison that is used on the variable value.
    • For value, enter the variable value that triggers the application of the visibility value.
    For a team, the format of the rule is visibility membership team. To create a visibility rule that is based on team membership, complete the following steps:
    • For visibility, set the value for the visibility in the Set to field.
    • For membership, select the membership type of the user in the team.
    • For team, select the team that the user belongs to.

    To add more variable values or team memberships to a rule, click Add. Subsequent clicks add a variable value or team membership for each click. If there are multiple variables or team memberships in a rule, each of them has an AND relationship with the other. That is, all of them must be true for the rule to apply.

  4. Create more rules as needed.
By script
Select Script and then create a visibility script:
  1. Click Select.
  2. Select one or more local variables that trigger the script to run.
  3. Type JavaScript code into the field.
    The following parameters are available for your code:
    Parameter Description
    context The context parameter contains data from context.bpm.system, context.bpm.team.member, and context.bpm.team.manager. The system, member, and manager objects are identical to objects that have the same name in the view.context object.
    Remember: If your script checks the team membership and multiple teams have the same name in the process application and its dependent toolkits, the membership in those teams must be the same. If the team membership is not the same, use rules instead of a script to set the visibility.
    event The event parameter contains data from the initialize or change event. The framework calls the visibility script by using the initialize event (type: "initialize") during the coach initialization. The framework calls the visibility script with the change event (type: "change") when one of the watched variables changes. The change event is similar to the one that is handled by the change() event handler except that it has the following extra properties:
    • type: "change" or "initialize"
    • path: fully qualified path to the variable that changed. For example, type "local.employee.phoneNumber[2].areaCode"
    local The local parameter contains all the human service variables that are available to the coach. For example, you can get a variable value by using a call like local.get("employee").get("phoneNumber").get(0).get("type")

    In your JavaScript, each return value must be a string with one of the following values: REQUIRED EDITABLE READONLY NONE DEFAULT HIDDEN.

    When a user changes the value in one of these watched variables, the resulting change event causes the script to run. For example, you might want the user interface to display a coach view when the user selects tea from the MyDrink brand. Users from the sales team can edit the coach view. The service has Drink and Brand variables. You select these variables and then add the following code into the field:
    if(local.get("brand") == "MyDrink" && local.get("drink") == "Tea") {
    	if(context.bpm.team.member.indexOf("SalesTeam") != -1) {
    		return "EDITABLE";
    	} else {
    		return "READONLY";
    	}
    } else {
    	return "NONE";
    }