Pass OperationReason control to a workflow when triggered from a PS script?

Hello, we are triggering an on-demand workflow from a Powershell script using Set-QADObject but we need to record the request reference number as the OperationReason in the workflows activity operation so if someone checks the users change history the reference number should be recorded in the "reason" box next to the operation performed by the workflow

Example of code we are using:

$workflowParams = @"
    <RunParameterValues xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:schemas-quest-com:ActiveRolesServer:WorkflowParameters">
      <RunParameterValue name="userDN" syntax="String">
        <Values>
          <Value isEncrypted="false">
            <RawValue>$userDN</RawValue>
          </Value>
        </Values>
      </RunParameterValue>
      <RunParameterValue name="mbxLimit" syntax="String">
        <Values>
          <Value isEncrypted="false">
            <RawValue>$mbxLimit </RawValue>
          </Value>
        </Values>
      </RunParameterValue>
     </RunParameterValues>
"@

Set-QADObject -Identity $WorkflowDN -ObjectAttributes @{edsvaStartWorkflow=$true;edsvaWorkflowRunParameerValues=$workflowParams} -Control @{OperationReason="RITM580647 - Test"}

The -Control doesnt do it.

Also looked at this ADSI approach but still cant find a way of passing a string to a workflow activity operation reason.

Then found this but cant see a way passing a workflow parameter to the Control Value

Any advice is appreciated for this seemingly simple task.

Parents
  • An activity inside an Automation Workflow can set an operation reason, but this functionality is very limited - currently, Workflow activities can only set a hard-coded operation reason. In your case, you would want to set a different ticket number every time, so that won't work.

    In order for this to work as desired, the activity run by the Automation Workflow would have to be a custom script module. It can pull out a custom Workflow parameter value using $workflow.Parameter(name) to get the ticket number and then leverage that value on the Set-QADObject cmdlet against the object modified by the scripted activity.

Reply
  • An activity inside an Automation Workflow can set an operation reason, but this functionality is very limited - currently, Workflow activities can only set a hard-coded operation reason. In your case, you would want to set a different ticket number every time, so that won't work.

    In order for this to work as desired, the activity run by the Automation Workflow would have to be a custom script module. It can pull out a custom Workflow parameter value using $workflow.Parameter(name) to get the ticket number and then leverage that value on the Set-QADObject cmdlet against the object modified by the scripted activity.

Children