Web Form Functionality with Dynamic Constraints

1434
10
Jump to solution
01-11-2023 02:39 AM
SamGatter
New Contributor III

Hiya,

I have encountered an issue with using functions in the constraints column that are working fine in connect and the S123 app, however when publishing and trying to use the form in the web, the functionality breaks.

In my survey form I have several constraints that prevent the user from inputting a date within a certain time frame, in my example there are two unique time frames that need to be used that are based off a previous selection the user makes.

There are two methods that I have attempted that work in connect, but not the web:
   Using another field to calculate the time frame dynamically
I.e. 
This is the calculation for a field called date_constraint_fine
   if(selected(${solution_type},'Survey_123'),7, if(selected(${solution_type},'Quick_Capture'),7, if(selected(${solution_type},'Web_App'),7, if(selected(${solution_type},'Dashboard'),7, if(selected(${solution_type},'Web_App_3D'),7, if(selected(${solution_type},'Map'),7, 1))))))
Then this value is pulled into the constraint of another question
   (.>= ${scope_date_req}) and (.>=${scope_date_req} + (1000 * 60 * 60 * 24 * ${date_constraint_fine}))
   
   Using nested if statements within the constraint column
I.e.
   if(selected(${solution_type},'Survey_123'),(.>= ${scope_date_req}) and (.>=${scope_date_req} + (1000 * 60 * 60 * 24 * 21)),
if(selected(${solution_type},'Quick_Capture'),(.>= ${scope_date_req}) and (.>=${scope_date_req} + (1000 * 60 * 60 * 24 * 21)),
if(selected(${solution_type},'Web_App'),(.>= ${scope_date_req}) and (.>=${scope_date_req} + (1000 * 60 * 60 * 24 * 21)),
if(selected(${solution_type},'Dashboard'),(.>= ${scope_date_req}) and (.>=${scope_date_req} + (1000 * 60 * 60 * 24 * 21)),
if(selected(${solution_type},'Web_App_3D'),(.>= ${scope_date_req}) and (.>=${scope_date_req} + (1000 * 60 * 60 * 24 * 21)),
if(selected(${solution_type},'Map'),(.>= ${scope_date_req}) and (.>=${scope_date_req} + (1000 * 60 * 60 * 24 * 21)),
(.>= ${scope_date_req}) and (.>=${scope_date_req} + (1000 * 60 * 60 * 24 * 7))))))))

 

There is also an issue I have encountered when using readonly functions as well
These are 3 unique questions:

${solution_status}='Staging' or ${solution_status}='Production' or ${solution_status}='Launch'
${solution_status}='Production' or ${solution_status}='Launch'
${solution_status}='Launch'

Whilst this works in connect and the app, the functionality breaks when using it in the Web, i.e. all the questions don't go readonly. 

I have attached a copy of the relevant part of the survey that has this functionality. 

I would like to understand if there are any limitations when using functions in this way in a web form, or if there is a work around to this issue. 

Please let me know if you need me to go into any more detail.

Thanks,
Sam

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

I remember someone else posted doing dates with all this math and had issues.

I just use by days like this and it worked better for them.  This is 7 days.

${CalibrationDate} < date(decimal-date-time(now()) -  7)

Other thing I would try is the bind::type field to date.  Web seems to be picker on this.

Hope that does it

View solution in original post

10 Replies
DougBrowning
MVP Esteemed Contributor

I have a guess.  Sometimes things like .>= get counted as html.  I cannot remember the exacts.  Sometimes a space in there does it but really I would try replacing all the dots with the actually ${FieldName}.  This has got me a few times to the point I do not use the dot as much now.

Should be a easy find replace in notepad then paste back in.  Worth a shot.

0 Kudos
SamGatter
New Contributor III

Hi Doug,

Thanks for the suggestion, I have just tried this method by replacing all instances of the '.' with the field name, and whilst it still works in connect it doesn't when using the web form. 

That's a good tip though, it's not something I have thought about! 

SamGatter
New Contributor III

I have raised this with ESRI as a bug as well.

DougBrowning
MVP Esteemed Contributor

I remember someone else posted doing dates with all this math and had issues.

I just use by days like this and it worked better for them.  This is 7 days.

${CalibrationDate} < date(decimal-date-time(now()) -  7)

Other thing I would try is the bind::type field to date.  Web seems to be picker on this.

Hope that does it

SamGatter
New Contributor III

Hi Doug,

I didn't get a chance to try this, however my bug case was followed up and this was also their solution, which I'm glad to say works! i.e. using the decimal-date-time function instead of Unix to calculate the time. 

Thanks for your help Doug! 

ahargreaves_FW
Occasional Contributor III

I'm struggling with a constraint issue in a text field that is also in a web form but much simpler than yours. I've tried all of the following to ensure my text field isn't left blank but all still allow the user to submit a blank entry:

  • ${NOTE}!=""
  • string-length(${NOTE})!=0
  • string-length(${NOTE})>0
  • int(string-length(${NOTE}))!=0
  • int(string-length(${NOTE}))>0

What am I doing wrong here?

DougBrowning
MVP Esteemed Contributor

I have seen this.  Have you tried just using required?

0 Kudos
ahargreaves_FW
Occasional Contributor III

That's some "outside the box" thinking there @DougBrowning ! 😉

'Required' works but all I want for christmas is for my constraint to work...

DougBrowning
MVP Esteemed Contributor

Yea it happened to me also and I don't remember ever figuring it out.  It works for ints but not string.  Then I was like well required just does it for me :).  

0 Kudos