10 Replies Latest reply on Sep 3, 2019 3:17 PM by Phillip Brockhaus

    If then....else

    Alessandro Fenzi
      Share This:

      Hi,

      Probably this question was asked more than once. How to implement the if then ... else logic in a single set field?
      For example
      If A = green -> set field = Yes else set field = No

      The content of field A is only available within the If Action

        • 1. Re: If then....else
          Ranjit Jadhav

          Which workflow are you using? I mean are you on AR Server - Filter or Innovation Suite - Process?

           

          As you mentioned Set Field I assume you are using AR Filter.

          You can create Filter on Submit/Modify on given Form, use "Run If Qualification" of filter to specify If condition and add action set field in "If Actions" to set the field value = Yes. And in same Filter you add set field action in "Else Actions" to set the field value = No. In this case when condition evaluates to true, server executes "If Actions" else it executes "Else Actions"

           

          ...Ranjit

          1 of 1 people found this helpful
          • 2. Re: If then....else
            Alessandro Fenzi

            Sorry I forgot the plattaform version AR Server 9.0.00.002, so Developer Studio 9.0.00.

            Thank you for the answer

            • 3. Re: If then....else
              Laurent Matheo

              Discussion successfully moved from Developer Community to Remedy AR System

              • 4. Re: If then....else
                LJ LongWing

                Alessandro,

                You just described both an Active Link and a Filter....the Run-If qualification is the If, and you can have both if actions and else actions.  So....based on your specific request...no.....but, with two pieces of workflow, the first that gets the value and sets a temp field, and a second piece of workflow that does the if/then/else.

                2 of 2 people found this helpful
                • 5. Re: If then....else
                  rodrigo barcat

                  As Lj said, you put all of you object in just one line.

                   

                  your run if is 'field' = "green"

                   

                  then you run a set field action with change field.

                   

                  I do not remember if filter has Change Field action. For me, active link makes more sense, because it is a change for current user.

                  If you need, we can put an example here.

                   

                  cheers

                  • 6. Re: If then....else
                    Sinisa Mikor

                    In case you meant that Run If Qualification has already steered workflow into If Action(s) and you wish to implement "if then... else" within that branch, you may still be able to use Set Fields action to achieve this.

                     

                    If you prepare back-end form with precalculated values (e.g. record with 'value of A' = "green" would also contain 'response' = "Yes", record with 'value of A' != "green" would contain 'response' = "No"), you could use Set Fields action to fetch response from your back-end form using ($A$ = "green" AND 'value of A' = $A$) OR ($A$ != "green" AND 'value of A' != "green") as qualification; it could be simpler ($A$ = 'value of A') if valid set of values of A is finite, but you'd need a record for each possible value.

                     

                    Obviously, I presume that initial value of A is available throughout the whole branch -- otherwise, it would have to be stored in temporary value as LJ LongWing suggested.

                    1 of 1 people found this helpful
                    • 7. Re: If then....else
                      Phillip Brockhaus

                      There are many ways to solve this.

                       

                      There are many times when I avoid having several filters/active links that are doing several "elses" for setting a field. As someone already mentioned, you can have it do a data-lookup to mapping table, or if you just want quick and dirty -

                       

                      You can do a SQL set fields action with a case statement in it. Just select from nowhere ("from dual" in oracle)

                      like:

                      select case

                         when 'remedy field' = 'Red' then 10

                         when 'remedy field' = 'Green' then 20

                         when 'remedy field' = 'Blue' then 30

                         else 40

                      end

                       

                      And then set the field you want with $1$

                      3 of 3 people found this helpful
                      • 8. Re: If then....else
                        Alessandro Fenzi

                        All suggestions are good, my purpose was to don't create a field to hold a value, but check it at "run time". Anyway my environment has now a new field

                         

                        • 9. Re: If then....else
                          rodrigo barcat

                          So, If you do not want to hold the value (in the db), you can use a display field, right?

                          • 10. Re: If then....else
                            Phillip Brockhaus

                            Yes. You can use a display only field for interim processing if you need to temporarily hold a value.