build a variable of operator's approval groups

to meet our change management approval needs, we have added an array to the assignment table that contains a list of approvers for each assignment.  each approver operator has the same change profile which puts them all in the same cm3groups record.  right now, all approvers are able to approve any change, and i need to add logic to limit approval capabilities based on assignment.  


my thought was to create a new variable in login.default that would hold all assignments that an operator is an approver for, then use that variable in my approval conditions.  if i make my query approvers=operator(), my variable contains the first assignment the operator is an approver for. if i make my query operator() isin approvers, my variable is null.  


i have a partial workaround that involves a query/calculation on the cm3r format control, but this only solves the issue of approval permissions.  i'm still left without a way to setup an inbox/view to show operators changes pending their approvals.


is there a different way for me to format my query on login.default or another solution altogether that could capture an operator's approval groups from the array in assignment?

  • You can't use the OOB Approve option in the change queue, it requires that change profiles be configured as designed to assign approval privileges.


    However, you can define a view which will display the changes pending approval instead of using the Approval display option. Request Management Quotes use this method OOB.


    The view query would be similar to:

    $lo.custom.approval.list isin current.pending.groups


    If any of the groups in the first list are present in the current.pending.groups array, the matching records will be returned. You can look at the Quotes requiring my approval view to see an example of a similar query.

  • the trouble i'm having, though, is getting the variable populated with the approval groups.  once i have that, i think updating the inbox should be pretty straightforward.  any ideas how to get that variable filled in?

  • Update the login.DEFAULT format contol with a calculation to initialize the approval groups variable. The operator file is already the referenced file at login.DEFAULT.


    So if your approval list added to operator field name is myApprovalGroups then:

    $lo.myApprovalGroups=nullsub(myApprovalGroups in $file, {})


    Note that this will not include the operator's ID (if they need to approve something specifically assigned to them as an approval. To add that to the variable, use a second calculation:

    $lo.myApprovalGroups=$lo.myApprovalGroups {$}

  • the operators are in an array in the assignment table.  i had thought about also creating a new array field in the operator table and trying to keep the approval info in sync between assignment and operator in the same way that the assignee values are kept in sync, but it seemed like it would be overly complicated to figure out how to cycle through each assignment group looking for the operator then adding or removing the assignment depending on the need and dealing with potential duplicates.


    what about using javascript on login.default to cycle through all assignment records looking for the operator then adding the assignment to an array and assigning that to a variable?  i have no idea how to do that, but that could work, right?

  • Verified Answer

    i found a solution, so i thought i'd share it.



    add the following calculation to the login.default format control


    calculation: $lo.approver.query="approvers=\"" $ "\""

    add: true



    add the following subroutine to the login.default format control


    application name: build.list

    names: query, name, names, string1, booleans, sort

    values: $lo.approver.query, assignment, $G.approver.list, name, true, name

    add/update/before: true



    $G.approver.list holds all of the assignments the current operator is an approver for, and can be used in the display option conditions. then i set my inbox query


    current.phase="Approval" and approval.status="pending" and assign.dept isin $G.approver.list and current.pending.groups isin approval.groups in $G.cm3r.environment and (releaseCandidate=NULL or releaseCandidate=false)