4 Replies Latest reply on Jan 20, 2021 12:34 AM by Stephan Hillmann

    Run command if workflow fails; ignore if success

    Dianna Gibbs Seasoned Veteran

      I have been reading and researching and not sure I have found how to do this simple.  I have a workflow, and if it fails, I want to run a command and if successful, ignore the command.  I do not want the whole workflow to fail or other commands and tasks to not complete, only to run this command if it fails.

        • 1. Re: Run command if workflow fails; ignore if success
          user126898 Guru

          Here is one example.  If you look at the pmcmd below the very last parameter is RC=$?.  What this will hold is a 0 or 1.  0 for success and 1 for failure.  So basically if you configure the workflow correctly to fail when you want this will capture this.  Then in the IF block you check the output and run the script/command you want.


          You may have to change how you execute the workflow but this is the only way I found to work in your situation. 







          pmcmd startworkflow -sv $INFA_SVC -d $INFA_DOMAIN -u $INFA_USER -p $INFA_PASS -f CHE -paramfile  $PMROOTDIR/BWParam/che_audit_post_${FAC}.par -rin wf_CHE_AUDIT_POST_${FAC} -wait wf_CHE_AUDIT_POST




          if [[ $RC != 0 ]]


          echo "* An error occurred while attempting to run wf_CHE_AUDIT_POST in folder CHE for ${FAC}."

          exit 1


          echo "* The workflow wf_CHE_AUDIT_POST in folder CHE ran successfully for ${FAC}."


          • 2. Re: Run command if workflow fails; ignore if success
            Stephan Hillmann New Member

            You can also check inside the workflow the conditions and states of every session. If a session fails that makes it neccessary to run the command you can add the condition $your_session_name.Status!=SUCCEEDED or $your_session_name.Status=FAILED to the link that connects the session with the command task. You can also connect all relevant sessions to this command task and add conditions like described.


            It is also possible to decide if a workflow fails when a session fails. Therefore there is a check box in the first window when editing a session.


            If you want to handle this outside informatica PC via a script then Scotts answer is a good solution.

            • 3. Re: Run command if workflow fails; ignore if success
              Nico Heinze Guru


              with all due respect, but $RC will only catch the return value of the pmcmd startworkflow command, not necessarily the status of the workflow. You know, if the workflow wouldn't start e.g. because the given credentials don't have Execute permission in that folder, pmcmd startworkflow will fail, but the workflow did not run at all. The original question does not give any indication whether this would be part of the desired result, so your approach is not necessarily exact "enough".



              Basically there's only one way to go. You need to find out (e.g. using the batch functionalities of the Web Services Hub if you have licensed it, a pmcmd invocation, or something similar) whether the workflow failed. If so, the command must be executed. If not, the command shall not be executed.

              You can do that using a batch file, a shell script, or another workflow, or some "real" enterprise-wide scheduling system (because that's not part of the built-in functionality).

              The first three approaches require that the respective credentials for requesting runtime details about the workflow in question must be explicitly "stored" somewhere where the respective process (the batch file, the script, the Web Service Hub... whatever) can "find" those credentials and use them.


              That's a typical scenario for an enterprise-wide scheduling system; such requirements go beyond what the built-in mechanisms provide easily.




              • 4. Re: Run command if workflow fails; ignore if success
                Dianna Gibbs Seasoned Veteran

                Thanks for the replies and information.  I doubt we have the licensing and more complex than what we need.  I only wanted to page to a phone if it failed and using our phone/text address thru Component if fail is not reliable, with nothing to do with Informatica.  Too many firewalls and channels to go thru.  A Schell script works perfect directly but we only want if failed.  For now, I have created a rule in email to forward to phone if workflow fails.  Thanks again for all the replies.  Appreciate it.