07-23-2019 01:32 AM
based on result of if/else i want to send email (next Task). so assume in a Powershell Task i have sample code as below:
$a = 1;
$b = 2;
if ($a -lt $b) {
write-host "Task is successful";
}
else {
write-host "Task failed";
}
in next Task if it was successful (means entered in if), send email to user and if it failed (means entered in else) send email to admin.
Logically script will get executed successfully in any case so it always Trigger the Task (linked with green connector) to send email to user but i want to force it to send email to admin (linked with red connector).
i tried Setting ${taskname.POWERSHELL_NATIVE_COMMAND_STATUS} = 0; in else part but this does not help either.
any Suggestion?
Solved! Go to Solution.
08-14-2019 03:32 AM
Hi Kaka,
I mean the standard task "If Else" which you can find in the directory "procedural tasks" in the workflow designer. :)
Regards,
Jessi
08-06-2019 12:32 PM
Hi KAKA_2,
is maybe the procendual task "If Else" an option for you?
Normally I'm using this to check a condition ... If the condition true you can using te first connector and send an email to the e.g. user - if the condition false, you can using the second connector to send an email to the administration. And from the email task you can go from the "success" connector to the "failed" task from the workflow to stop them.
Or you using a custom task ... I found these example in the UCS Director Cookbook:
Objective
Set the Task status to Successful or Failed based on the given condition.
Prerequisites
None
Components
ctxt - Used to set the status message of the workflow task.
Code
if (true) { ctxt.setFailed(“Error output message”); // to set the task status as failed ctxt.exit(); // to exit task flow normally } else { ctxt.setSuccessful(); // to set the task status to successful }
Results
Sets the task status as failed or successful based on the given condition.
Regards,
Jessica
08-14-2019 02:25 AM
Hello Jessica,
What do you mean by "procendual Task"? in this particular case i do not want to use custom Task.
Thank You.
-KAKA-
08-14-2019 03:32 AM
08-14-2019 05:10 AM - edited 08-14-2019 05:14 AM
Hello Jessi,
Thanks. finally i have found it. with first Impression i see that it look for an condition as Input. in my case, result of Task contains either true or false so i believe i can create a Input variable and set result of prvious Task in this variable which can be later used as test Expression.
I will give a try and see if this works.
Thanks for your help.
-KAKA-
08-16-2019 03:21 AM
Hello Jessi,
IFElse Task is doing exactly what i was looking for. Thanks for your help.
-KAKA-
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide