GCV, Mapping tables and a real improvement in my code.

GCV, Mapping tables and a real improvement in my code.

So with very little time before the start of the school year we were told we were closing four locations, opening two new locations immediately, with two more locations coming in the months to come. For me this meant a need to make code changes in IDM. The area of greatest concern was the large number of email lists we maintain, many of which are location based. This means we have lists of all adjuncts by location and we have all full-time employees by location.



These were hard to maintain, sometimes not all the same and really no fun when locations are rapidly changing. So the first step was to go read Cool Solutions and find that article I had read on GCVs. I found a mention of the list type and a notation that it could be used in a for/each loop. And I knew that I had the start to a solution where I could list each of the locations.



locationgcvlist



This list type GCV has a list of each of my campuses listed with the name short name assigned to each campus and already on each user who is working at a campus. This is easy to maintain adding a new campus here is just a few minutes work.



Next I needed a mapping table, I have used them many times before just never combined with a list type GCV. So the first column contains the exact same location information and each of the other columns contains the name of the email list I need to maintain. Once again, the amount of time it takes to add a new row for a campus here is very minor. It is also a reminder of each of the new location groups that I need to create.



Finally the code that pulls this all together. I begin with the For Each loop and reference the GCV that has every campus. I then set two local variables, one with the name of the list from the mapping table, and one with the value from the user of the location(s) where they work.



The code to add to the groups starts by seeing if the value from the GCV matches the local variable with the user’s location in it. If it matches that we need to see if they meet the requirements of this list, if they don't we can move on to the remove code. My code is complicated by the fact that my source of information on users location can be wrong and it is easier for me to give my help desk a way to fix this rather than alter the authoritative source so I have both add and remove groups for every email group to allow them to alter the results as needed.



The Code to remove them starts by using the name variable along with a variable that is set to the location of the group, like (\tree\novell\groups\email) and then the variable that was originally set with the list name. If they are in the group then we must test to see if they should be removed, if they are not then we move on.



This method of writing code has made a dramatic improvement to my process of populating email lists. The original code was pages and pages of code by location, the new code is one large loop that can test for all locations and makes the addition or removal of a new campus a very simple procedure to follow. All that is needed is a new location added to the list GCV, a new row in the mapping table, the creation of the groups and adding a new location just went from a week long effort to a matter of a few hours.



locaitongroups



 

groupcode



 


<rule>
<description>Break if not need to run this policy</description>
<conditions>
<and>
<if-op-attr name="multiLocations" op="not-changing"/>
<if-class-name mode="nocase" op="not-equal">User</if-class-name>
</and>
<and>
<if-operation mode="case" op="not-equal">sync</if-operation>
<if-attr name="employeeStatus" op="not-available"/>
<if-class-name mode="nocase" op="not-equal">User</if-class-name>
</and>
</conditions>
<actions>
<do-break/>
</actions>
</rule>
<rule>
<description>Web Location Groups</description>
<comment xml:space="preserve">This code adds and removes uses from the dmail groups named for the locations . It uses a GCV idv.siteLocation.List and loops though these. It uses the mappping table lib-Damil-Location-Groups for information on each location. </comment>
<comment name="author" xml:space="preserve">SWT</comment>
<comment name="version" xml:space="preserve">2</comment>
<comment name="lastchanged" xml:space="preserve">8/20/2015</comment>
<conditions>
<and>
<if-attr name="siteLocation" op="available"/>
</and>
</conditions>
<actions>
<do-for-each>
<arg-node-set>
<token-global-variable name="idv.siteLocation.list"/>
</arg-node-set>
<arg-actions>
<do-set-local-variable name="lcl.acd.name" scope="policy">
<arg-string>
<token-map dest="location_webroles" src="siteLocation" table="..\..\Library\lib-Dmail-Location-Groups">
<token-local-variable name="current-node"/>
</token-map>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="lcl.sitelocation" scope="policy">
<arg-string>
<token-attr name="siteLocation"/>
</arg-string>
</do-set-local-variable>
<do-if>
<arg-conditions>
<and>
<if-local-variable mode="regex" name="lcl.sitelocation" op="equal">.*($current-node$).*</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-if>
<arg-conditions>
<and>
<if-attr mode="nocase" name="Group Membership" op="not-equal">$idv.location.group.location$\$lcl.acd.name$</if-attr>
<if-attr mode="nocase" name="Group Membership" op="not-equal">$idv.location.group.exception.remove.location$\$lcl.acd.name$</if-attr>
<if-attr mode="nocase" name="employee" op="equal">TRUE</if-attr>
</and>
<and>
<if-attr mode="nocase" name="Group Membership" op="equal">$idv.location.group.exception.add.location$\$lcl.acd.name$</if-attr>
</and>
</arg-conditions>
<arg-actions>
<do-add-src-attr-value name="Group Membership">
<arg-value type="string">
<token-global-variable name="idv.location.group.location"/>
<token-text xml:space="preserve">\</token-text>
<token-local-variable name="lcl.acd.name"/>
</arg-value>
</do-add-src-attr-value>
</arg-actions>
<arg-actions/>
</do-if>
</arg-actions>
<arg-actions/>
</do-if>
<do-if>
<arg-conditions>
<and>
<if-attr mode="nocase" name="Group Membership" op="equal">$idv.location.group.location$\$lcl.acd.name$</if-attr>
<if-attr mode="nocase" name="Group Membership" op="not-equal">$idv.location.group.exception.add.location$\$lcl.acd.name$</if-attr>
</and>
</arg-conditions>
<arg-actions>
<do-if>
<arg-conditions>
<or>
<if-local-variable mode="regex" name="lcl.sitelocation" op="not-equal">.*($current-node$).*</if-local-variable>
<if-attr mode="nocase" name="employee" op="not-equal">TRUE</if-attr>
<if-attr mode="nocase" name="Group Membership" op="equal">$idv.location.group.exception.remove.location$\$lcl.acd.name$</if-attr>
</or>
</arg-conditions>
<arg-actions>
<do-remove-src-attr-value name="Group Membership">
<arg-value type="string">
<token-global-variable name="idv.location.group.location"/>
<token-text xml:space="preserve">\</token-text>
<token-local-variable name="lcl.acd.name"/>
</arg-value>
</do-remove-src-attr-value>
</arg-actions>
<arg-actions/>
</do-if>
</arg-actions>
<arg-actions/>
</do-if>
</arg-actions>
</do-for-each>
</actions>
</rule>
</policy>


Labels (1)

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
4 of 4
Last update:
‎2020-03-10 19:07
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.