Hi,
We're trying to create a workflow that counts every time a user enables or disables another user every day (workflow trigger is the modifivation of edsaAccountIsDisabled). (the counter resets every day.) If the counter reaches 20, the action requires approval.
We tried to store the counter in a virtual attribute like so:
function addOne ($Request) { $aidcounter = $workflow.savedobjectproperties("Save object properties").get("edsva-aidcounter") $aidcounternew = $aidcounter+1 return $aidcounternew }
We must use saved objct properties here because we are trying to access the original initiator's properties.
Now, this method simply didn't work. We weren't able to call the saved properties via script. We got the following error:
Exception calling "SavedObjectProperties" with "1" argument(s): "The given key was not present in the dictionary."
As a workaround, we tried to first copy the edsva-aidCounter of the initiator into another VA called TEMP-int of the TARGET, and then we called it via script like so:
function addOneTemp ($Request) { $user = $request.dn $counter = get-qaduser -proxy -identity $user -includeallproperties | Select-Object -expandproperty TEMP-int $counternew = $counter+1 return $counternew }
When testing this script outside of the AR workflow, (replacing $request.DN with the DN of a test user), this worked perfectly.
However, for some reason, when this workflow is triggered, $counter always returns an empty value, and so $counternew is always 1.
Obviously, the ideal solution is for "saved object properties" to work correctly when called from the PS script (I have not yet seen a functioning example of this, in forums usually an alternative solution is suggested where they end up not using saved object properties at all in the final script), but if that doesn't work, we'd still like to understand why our workaround doesn't work. ($counter always returns empty)
We used a nearly identical script as a counter before for different attributes, worked fine.
We'd appreciate any help!
Thanks