Cannot retrieve saved object properties by script in workflow

Hello,

I'm trying to create a workflow that will update user's description if the company or TAM_AppsScope attributes are modified.

Company is the AD attribute (single string) whereas TAM_AppsScope is an ARS VA (multi-valued string).

In my workflow I have the 2 following activities:

1- "TAM Updated Properties" which is a Save object properties-type activity:

Target: Workflow target

Saved properties: Company, TAM_AppsScope

2- "Update Description" which is an Update-type activity:

Target: Workflow target

Updated property: Description -> Set -> Script (TAM - Update Attributes) -> Run Update-TAMDescription function

Here is the script:

function Update-TAMDescription ($Request,$Workflow)
{
    $USER_AppsScope = $Workflow.SavedObjectProperties("TAM Updated Properties").get("TAM_AppsScope")
    $USER_ExtCompany = $Workflow.SavedObjectProperties("TAM Updated Properties").get("company")

    $ReadableApps = $USER_AppsScope -join ", "
    $USER_ComputedDescription = "$USER_ExtCompany TAM account for application(s): $ReadableApps"
    return "test"#$USER_ComputedDescription
}

When doing an update on the requested attributes, the workflow runs into an issue with the following error:

  • Activity 'Update Description' encountered an error. 
     Details <<<
    At line: 3 char:5. You cannot call a method on a null-valued expression.

It seems that ARS does not like the $Workflow.SavedObjectProperties lines, tried to comment the first one as it is the multi-valued attribute but it is the same error at the next line for single-valued string Company.

Have you any idea if I missed something?

  • If your "TAM_AppsScope" property is  getting a new value being applied (and this is what your workflow is intercepting), then you can get its contents using $Request.Get("TAM_AppsScope") - you don't need to use a Saved Object Properties Activity.

    So:

    $USER_AppsScope = $Request.Get("TAM_AppsScope") # Get the inbound value for this property as found in the current transaction 

  • Thank you Johnny!

    Indeed it retrieves correctly the updated value from the $Request object. The trickiest part is that the 2 properties are not subject to change at the same time. The company may change but not the appsScope and vice versa.

    I opted for Get-QADuser cmdlet to retrieve the other not-updated value when only one is modified:

    $USER_AppsScope = $Request.Get("TAM_AppsScope")
    if(!($USER_AppsScope)){$USER_AppsScope = (Get-QADUser $Request.DN -Proxy -IncludedProperties TAM_AppsScope).TAM_AppsScope}

    It's acceptable, it seems not adding so much time on workflow execution. But I don't know if it's the best solution or a workflow built-in process will suit better this case than a QAD request?