5

I have a parallel task in the step function that contains two branches. The input was:

{
  "database": "test",
  "userName": "tester",
  "userID": "test123",
  "adGroup": "testADGroup",
  "dbGroup": "ReadGroup"
}

Each branch return a json result like the following

Branch 1 (I used "OutputPath": "$"):

{
  "requestType": "GrantAccess",
  "DBUser": "exists",
  "ADUser": "exists"
}

Branch 2 (I used "ResultPath": "$.approvalStatus"):

{
      "database": "test",
      "userName": "tester",
      "userID": "test123",
      "adGroup": "testADGroup",
      "dbGroup": "ReadGroup"
      "approvalStatus": "Approved"
}

When both the branches complete, the output of the parallel task return:

[
  {
      "requestType": "GrantAccess",
      "DBUser": "exists",
      "ADUser": "exists"
  },
  {
      "database": "test",
      "userName": "tester",
      "userID": "test123",
      "adGroup": "testADGroup",
      "dbGroup": "ReadGroup"
      "approvalStatus": "Approved"
  }
]

The next task is a choices,

"Choices": [
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Approved",
      "Next": "ProcessRequest"
    },
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Declined",
      "Next": "SendDeclineNotification"
    }
  ]

and it is keep giving me the following error:

"cause": "An error occurred while executing the state 'CheckApprovalStatus' (entered at the event id #16). Invalid path '$.input[1].approvalStatus': The choice state's condition path references an invalid value."

So here are my questions,

1) How should I reference it in the choice task to get the approvalStatus value?

2) Is there are anyway I can make the parallel task return in json format instead of an array?

Thanks in advance

2
  • so i think i have solved it by adding "ResultPath":"$.request" in the parallel task, changing branch2 "ResultPath": "$.approvalStatus" to "OutputPath": "$", and change all the reference in the following tasks to "Variable": "$.request[1].approvalStatus" Commented Jul 20, 2017 at 14:31
  • 1
    2) I agree. It would be nice if they did it like the node Async module and let you specify parallel states in an object instead of an array and then put the results in an object with the corresponding property names. Relying on array indexes for the parallel results makes the code fragile. Commented Aug 25, 2017 at 22:44

1 Answer 1

8

I think you should use something like "$[1].approvalStatus" if you don't want to change the ResultPath.

Sign up to request clarification or add additional context in comments.

1 Comment

@user3646699 This should be the accepted answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.