cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using Workflow Action to set value on attributes of objects linked to Workflow Subject

pvandeginste
Honored Contributor

Hi,

 

I'm trying to configure a workflow action, so that when a manager approves a Project via a workflow in HOPEX, certain attributes of the objects "elements of the project" get updated automatically. Here is the script I tried:

 

Function ExecuteAction(objWorkflowContextAction, strParameter)
 Dim mgRoot, mgobjWorkflowAction, mgobjWorkflowSubject, mgobjWorkflowInstanceDescription, blnUpdatorModified
  Set mgRoot                           = context.GetRoot
  Set mgobjWorkflowAction              = context.GetWorkflowAction
 Set mgobjWorkflowSubject             = context.GetWorkflowSubject
 Set mgobjWorkflowInstanceDescription = context.GetWorkflowInstanceDescription

  If (mgobjWorkflowAction.Exists and mgobjWorkflowSubject.Exists and mgobjWorkflowInstanceDescription.Exists) Then
 if mgobjWorkflowSubject.gettype("~qekPESs3iG30[Work Package] ").exists then
 dim cts, ct
  set mgobjWorkflowSubject=mgobjWorkflowSubject.gettype("~qekPESs3iG30[Work Package] ")
     cts=mgobjWorkflowSubject.getcollection("~Qv5U(F8v9HfG[Element of the Project] ")
        if cts.count > 0 then
          for each ct in cts
            if ct.gettype("~c)8zXsFNLb)6[Validation Target] ").exists then
             set ct=ct.gettype("~c)8zXsFNLb)6[Validation Target] ")
              ct.setprop "~Qz8zZyFNLXE7[Governance Status] ","VALA"
              ct.setprop "~(oGAQcI5NrVN[Promotion Status] ","PAP"        
            end if
          next
        end if
 end if
  End If
End Function

 

I can't seem to get the attributes to update the desired values. Can someone point out what I might be doing wrong (my VBscript isn't that great 🙂 )

 

thanks,

Philippe

3 Replies

Thank you both for the feedback. It was encountering an error in the IF statement. I had forgotten that the "element of the project" collection returned items of that abstract type. After adding a statement to get the physical MetaClass of each item in the collection, it worked.

 

Thanks!

SVanSchoonlandt
Honored Contributor

You are sure he is going inside the if condition for the update right?

Are you trying to update a metaAttribute of type Enumeration ?

hsoegaard
MEGA Partner
MEGA Partner

Not sure if this will help, but the following will update a new date fields we have added to the Validation metaclass, using the Request for validation.

 

Function ExecuteAction(objWorkflowContextAction, strParameter)
  ExecuteAction = ""
  ' ----
  Dim mgobjValidation,  mgobjTransition
  Set mgobjValidation = objWorkflowContextAction.GetWorkflowSubject
  Set mgobjTransition = objWorkflowContextAction.GetWorkflowTransition
  If (mgobjValidation.Exists and mgobjTransition.Exists) Then
   
    ' ----
    Dim  mgobjValidateCandidateObject
    Set mgobjValidateCandidateObject = mgobjValidation.GetCollection("~8d4R6x6MGbWB[Validation Candidate Object]").Item(1)
    If (mgobjValidateCandidateObject.Exists) Then
      Dim mgobjLockableObject, bLock
      bLock = FALSE
      Set mgobjLockableObject = mgobjValidateCandidateObject.GetTarget.GetType("~Ggq9LIpnFLo6[Lockable Object]")
      If (mgobjLockableObject.Exists) Then
       If (mgobjLockableObject.GetProp("~xkUUefdeFbqE[Immutability]") = "PROT") Then
          bLock = TRUE
          mgobjLockableObject.UnLock
        End If
      End If

      mgobjValidateCandidateObject.GetProp("~)ckmcDSlG9BB[Release Date <PE>]") = Now

      If (bLock) Then
        mgobjLockableObject.GetProp("~xkUUefdeFbqE[Immutability]") = "PROT"
      End If
      Set mgobjLockableObject = Nothing
    End If
    Set mgobjValidateCandidateObject = Nothing
  End If
  Set mgobjValidation = Nothing
  Set mgobjTransition = Nothing
End Function