If statement - Conflict in the expression

820
3
Jump to solution
06-25-2021 05:57 AM
PanGIS
by
Occasional Contributor III

Hello!

I am trying to make things work on a complex system of forms. Based on the same feature service I have different forms.

2 of them are involved in the following:

Form 1. according to the priority the status is defined:

Status= if(${Priority} ='Low', 'Pending', if(${Priority}='Medium', 'Pending' , if(${Priority} ='High', 'Pending', if(${Priority}='Critical', 'Pending', if(${Priority}='None','Closed/Rejected', 'Queue')))))

Form 2. once the work is done here the question: "Would you like to close the case?" change the Status into 'Ready for vetting'

Once the status changes the person has to reopenForm 1and answer the question: "Do you accept the solution?" has to reply yes or no and the status would change into

yes = 'Settled'

no = back to 'Pending'

in order to achieve so I added something to the end of my first if statement to get this:

Status = if(${Priority} ='Low', 'Pending', if(${Priority}='Medium', 'Pending' , if(${Priority} ='High', 'Pending', if(${Priority}='Critical', 'Pending', if(${Priority}='None','Closed/Rejected',if(${Accepted}='Yes','Settled', if(${Accepted}='No','Pending','Queue')))))))

no errors in the statements but when I reopen the form and set either yes or no to the Action question, the status goes to 'Pending' no matter what.

It is clear to me that there is a conflict and the {Priority} settings are honored and the {Accepted} is ignored.

any idea on how I could make this work?

I think I should insert AND somehow, I am trying but I keep on getting errors.

Thanks!

0Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Honored Contributor

That's a tough one since there are two fields and one trumps the others. So I think status needs to be the first check. Then you can eliminate a lot of ifs and use or to simplify.

I can't test it but try this.

Status = if(${Accepted}='Yes', 'Settled', if(${Priority} ='Low' or ${Priority}='Medium' or ${Priority} ='High' or ${Priority}='Critical' or ${Accepted}='No', 'Pending', if(${Priority}='None', 'Closed/Rejected', 'Queue')))

View solution in original post

3 Replies
DougBrowning
MVP Honored Contributor

That's a tough one since there are two fields and one trumps the others. So I think status needs to be the first check. Then you can eliminate a lot of ifs and use or to simplify.

I can't test it but try this.

Status = if(${Accepted}='Yes', 'Settled', if(${Priority} ='Low' or ${Priority}='Medium' or ${Priority} ='High' or ${Priority}='Critical' or ${Accepted}='No', 'Pending', if(${Priority}='None', 'Closed/Rejected', 'Queue')))

PanGIS
by
Occasional Contributor III

Amazing! It worked.

As soon as I have time I will review it carefully. I need to understand better how statements work.

Thank you!!!

0Kudos
jcarlson
MVP Esteemed Contributor

Are your users using the field app or web interface? You might consider using a third form for that final approval, then use Inbox filters to keep things organized. When your workflow has multiple steps that are all distinct, it may make more sense just to have a form for each.

- Josh Carlson
Kendall County GIS