Hi
We have a property called 'Manager Roles' which has a script grouping multiple Manager properties together. It is used in a My Staff view and means that the Manager only sees Employees his is a Manager of.
Our issue is the property causes delays when updating and creating docs that it exists on. Anything from 15 seconds to 60 seconds.
I would like to do away with it the property Manager Roles to improve user experience however I cannot work out a way to achieve the My Staff views so the Manager only sees the employees they are a Manager of and that they don't see a list of all staff and have to trawl through it to find their reportees.
Below is the filter on the view
Script in case
' Automatic Value for Multi-select Property.
' Description:
' Try to find eight (8) predefined single-select list type properties from the properties of this object. If we find content, add it to this multi-select property (both of these lists need to be of the same type). If there is no content in any of the three properties or all of the five properties are missing entirely from the metadata card, set this property as empty.
Option Explicit
Dim arrEmployeePropertyDefinitions(7)
' TODO:
' Change these to the property definition ID's of the three predefined properties.
' ######################################################################
arrEmployeePropertyDefinitions(0) = aliasToPropID("Manager")
arrEmployeePropertyDefinitions(1) = aliasToPropID("2nd Line Manager")
arrEmployeePropertyDefinitions(2) = aliasToPropID("3rd Line Manager")
arrEmployeePropertyDefinitions(3) = aliasToPropID("4th Line Manager")
arrEmployeePropertyDefinitions(4) = aliasToPropID("Additional User Permissions")
arrEmployeePropertyDefinitions(5) = aliasToPropID("Additional HR User Permission")
arrEmployeePropertyDefinitions(6) = aliasToPropID("HR User Permission")
arrEmployeePropertyDefinitions(7) = aliasToPropID("Content Approver")
' ######################################################################
' Create Mutex. Mutex is used to prevent several launches of the property calculation because we use SetProperty in the script which would normally cause an infinite loop.
Dim oMutexNamedValues: Set oMutexNamedValues = Vault.NamedValueStorageOperations.GetNamedValues( MFConfigurationValue, "Mutex" )
Dim szMutexKey : szMutexKey = ObjVer.ID & ":" & PropertyDef.ID
' Check the existense of this Mutex.
If VaultSharedVariables( szMutexKey ) = "x" Then
Else
VaultSharedVariables( szMutexKey ) = "x"
Dim iFoundLookupId
Dim arrFoundPropertyDefs : arrFoundPropertyDefs = Array()
Dim iIndex : iIndex = 0
Dim iNewIndex : iNewIndex = 0
' Create an array of unique list item ID's
For iIndex = 0 To UBound(arrEmployeePropertyDefinitions)
iFoundLookupId = GetLookupId( arrEmployeePropertyDefinitions( iIndex ) )
If iFoundLookupId <> -1 And GetArrayIndex( arrFoundPropertyDefs, iFoundLookupId ) = -1 Then
ReDim Preserve arrFoundPropertyDefs(iNewIndex)
arrFoundPropertyDefs(iNewIndex) = iFoundLookupId
iNewIndex = iNewIndex + 1
End If
Next
' Output the gathered array.
Output = arrFoundPropertyDefs
VaultSharedVariables( szMutexKey ) = ""
End If
Function GetLookupId( iPropertyDefinitionId )
GetLookupId = -1 ' Default value, indicates none found.
Dim iPropertyDefIdIndex : iPropertyDefIdIndex = PropertyValues.IndexOf( iPropertyDefinitionId )
If iPropertyDefIdIndex <> -1 Then
Dim oTypedValue : Set oTypedValue = PropertyValues.Item( iPropertyDefIdIndex ).Value
If oTypedValue.IsNull = False And oTypedValue.IsUninitialized = False Then
Dim oLookup : Set oLookup = oTypedValue.GetValueAsLookup
If oLookup.Deleted = False Then
GetLookupId = oLookup.Item
End If
End If
End If
End Function
' returns the index of obj in array. obj can be anything. Returns -1 if not found.
Function GetArrayIndex(arr, obj)
Dim x : x = -1
If isArray(arr) Then
Dim i
For i = 0 To UBound(arr)
If arr(i) = obj Then
x = i
Exit For
End If
Next
End If
GetArrayIndex = x
End Function
Function aliasToPropID( szAlias )
Dim iID
iID = Vault.PropertyDefOperations.GetPropertyDefIDByAlias( szAlias )
If iID = -1 Then
Err.Raise MFScriptCancel, "Alias is not found or more than one property definition uses the specified alias: " & szAlias
End If
aliasToPropID = iID
End Function
Any ideas greatly appreciated.
Regards
K