Creating a 'Run Rule' task that writes to context

Which IIQ version are you inquiring about?

8.3

As part of a test, I need to run a rule that extracts a value from the workflow context arguments:

if (wfcontext != null) {
  Attributes wfArguments = wfcontext.getArguments();
  if (wfArguments != null) {
    identityName = (String) wfArguments.get("identityName");
```

How can i write this information inside the task? I want to avoid changing the rule called, as that would trigger some internal politics.

You don’t need to change the rule. Just pass the identityName into the workflow context arguments from the task/workflow side. For example, in the TaskDefinition XML add it under <Attributes> (e.g. <entry key="identityName" value="test.user"/>). That way, when the task runs, the workflow context will already have identityName and the rule can read it with wfcontext.getArguments().get("identityName").

1 Like

A quick follow up: is there something I have to do to ensure wfcontext exists and is passed in?

You don’t need to do anything special—wfcontext is automatically created when the workflow is triggered. Just make sure to pass your arguments via the workflow’s input mapping or in the TaskDefinition <Attributes>. Then wfcontext.getArguments() will contain the values, like "identityName", for your rule to read.

There is no workflow. Normally, the rule is called from a workflow, but now I’m calling it from a task. Do i need to create a workflowcontext? Inside the rule, it says wfcontext is of type void.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.