Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional String publish based on Navigation result #978

Open
sarfaras opened this issue Mar 21, 2017 · 1 comment
Open

Conditional String publish based on Navigation result #978

sarfaras opened this issue Mar 21, 2017 · 1 comment

Comments

@sarfaras
Copy link

sarfaras commented Mar 21, 2017

Please tell me how can I,

  • Conditionally assign/publish a value in workflow based on navigation result from an operation
    Scenario is, Flow is going through different navigation route but finally I have to generate a user message where I have to call an operation generate message but only that I have to pass "currentState". I just want to limit invocation to "GenerateMessage" only in one place in flow but dynamically assign "currentState" variable in flow. Right now the challenge I have is, how do i achieve as below

Call OP1
- Publish "currentState" = "OP1 Failed" if OP1 failed (based on navigation result)
- Publish "currentState" = "OP2 Failed" if OP2 successful
- Publish "currentState" = "State1" if returnCode = 2

I know 3rd can be achieved with an equals operation but that seems to be lot to do to achieve small thing. Also I dont see an option for first two cases where I have to set a variable based on navigation result from operation. Thanks

@levice14
Copy link
Collaborator

good point

  • you can e.g.
  workflow:
    - op:
        do:
          ops.op: ..
        publish:
          - currentState: ${ 'OP2 Failed' if <FAILURE_CONDITION_FROM_OPERATION> else 'STATE1' }
        navigate:
          - EVEN: ..

do it with a Python expression - however in this case, you have to duplicate the result condition from the operation (which is not so good if the underlying op changes)

  • you can introduce an additional step (noop) to define your variables in its publish section and then navigate to the GenerateMessage step
  • or use two `Generate message' steps:
  workflow:
    - op1:
        do:
          ops.op: ..
        publish:
          - failure_message: # set failure message

    - op2:
        do:
          ops.op: ..
        publish:
          - success_message: # set success message
          - failure_message: # set failure message
          
    - generate_success_message:
        do:
          ops.generate:
            - message: success_message

    - on_failure:
      - generate_failure_message:
          do:
            ops.generate:
              - message: failure_message

see on_failure here

but, overall I think it would make a valid enhancement what you are suggesting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants