Workflow and get attributes than the changed attribute

Hello, 

I have this script in a workflow where the trigger is changed attribute extensionattribute1 OR physicaldeliveryoffice. Thing is that When one of these attributes change, the worklow is launche but  the script only can get the changed attributte.

In the same way, When one of these attributes is change I cannot get any oher attributes like DN or samaccountname. 

How can i get any other attribute in addition to the change attribute that launch the workflow.

 

function GetValue
{
param
(
$Request,
$Attribute
)

try
{
$Value = $Request.Get($Attribute)

if(-not $value)
{
$Value = $DirObj.Get($Attribute)
}

}
catch
{
$value = $null
}

return $value
}

function CalculOUdestination($Request){

$oupath = ",OU=Colisee,OU=Usuarios,DC=local,DC=colisee,DC=es"
$OU = ""

$code_eta = GetValue $Request "physicalDeliveryOfficeName"
$code_eta2 = $Request.get("physicalDeliveryOfficeName")

$dep_title = GetValue $Request "extensionAttribute1"
$dep_title2 = $Request.get("extensionAttribute1")
$code_user = GetValue $Request "sAMAccountName"
$code_user2 = $Request.get("sAMAccountName")

$OU = "OU="+$dep_title2+",OU="+$code_eta2+",OU=Colisee,OU=Usuarios,DC=local,DC=domain,DC=local"

return $OU

}

Top Replies

Parents
  • Hello, is the use case here to move the user to a new OU based on the values set in 'physicalDeliveryOfficeName' and 'extensionAttribute1'? If so, then there might be a solution to this that won't involve any code.

    Leave the Change workflow as is, which is to execute based on a change to either or both of these attributes. Then, within the bottom half of the workflow, under the 'Operation execution' section, place a Move workflow activity.

    Opening the Properties of the Move step, the 'Activity Target' would be the 'Workflow Target'. The 'Destination Container' would be set to 'Object identified by DN-value rule expression'. This is where you can build out the new OU destination, similar to what is being done in the above script. When clicking the 'Add entry' button, create the new OU location string by adding multiple values.

    Select 'Text strings' when clicking 'Add entry' and type in the hardcoded OU= location values

    Select 'Property of object from workflow data context' when wanting to insert an attribute value. From the 'Target object' select 'Workflow Target'. And for 'Target Property' select the attribute from the presented list (Office Location is in this default list) or select 'More choices' at the bottom to search for the attribute (extensionAttribute1). The resulting rule would look something similar to this:

Reply
  • Hello, is the use case here to move the user to a new OU based on the values set in 'physicalDeliveryOfficeName' and 'extensionAttribute1'? If so, then there might be a solution to this that won't involve any code.

    Leave the Change workflow as is, which is to execute based on a change to either or both of these attributes. Then, within the bottom half of the workflow, under the 'Operation execution' section, place a Move workflow activity.

    Opening the Properties of the Move step, the 'Activity Target' would be the 'Workflow Target'. The 'Destination Container' would be set to 'Object identified by DN-value rule expression'. This is where you can build out the new OU destination, similar to what is being done in the above script. When clicking the 'Add entry' button, create the new OU location string by adding multiple values.

    Select 'Text strings' when clicking 'Add entry' and type in the hardcoded OU= location values

    Select 'Property of object from workflow data context' when wanting to insert an attribute value. From the 'Target object' select 'Workflow Target'. And for 'Target Property' select the attribute from the presented list (Office Location is in this default list) or select 'More choices' at the bottom to search for the attribute (extensionAttribute1). The resulting rule would look something similar to this:

Children