Select to view content in your preferred language

Is it possible to make a Survey123 URL conditionally visible based on values being present in a particular field in the attribute table?

376
1
03-24-2023 05:16 AM
narmour1979
New Contributor

Hi

I am setting up a bridge inspection workflow for my customer. The inspection is in 2 parts:

1. 'Inventory' attributes of the bridge that are immutable and stored against the bridge asset. Recorded once and never changed. Eg. bridge type, construction material, span etc.

2. Inspection records that are recorded each time eg. condition, date, time, engineer etc.

Part 1 is recorded using a form in Field Maps where the inspector fills in the details.

Part 2 is recorded using Survey123 and stored in a related table. The survey form is accessed using the following URL which passes a number of attributes to the form in order to maintain the relationship in the table and to make the form filling a little less prone to errors:

https://survey123.arcgis.app?itemID=XXXXXXXXXXXXXXXXXXXXX&field:parentglobalid={GlobalID}&field:GIS_ID={GIS_ID}&field:AssetName={assetName}&field:surveyType=General
 
I'm trying to find a way of making part 2 inaccesible unless part 1 is filled out. 
 
I have tried using Arcade to conditionally provide the URL to the hyperlink in the popup using the following expression: 
 
          var errors = []; var i = 0

          if(IsEmpty($feature.type)){errors[i++]="1"}
          if(IsEmpty($feature.operation)){errors[i++]="1"}
          if(IsEmpty($feature.sizeType)){errors[i++]="1"}
         if(IsEmpty($feature.consequenceOfFailure)){errors[i++]="1"}
         if(IsEmpty($feature.span_m)){errors[i++]="1"}
         if(IsEmpty($feature.maxSoffit_m)){errors[i++]="1"}
         if(IsEmpty($feature.deckLength_m)){errors[i++]="1"}
         if(IsEmpty($feature.deckWidth_m)){errors[i++]="1"}

         var vals =(Concatenate(errors,","));

         if(IsEmpty(vals)){return "https://survey123.arcgis.app?               itemID=XXXXXXXXXXXXXXXXX&field:parentglobalid={GlobalID}&field:GIS_ID={GIS_ID}&field:surveyType=General&field:AssetName1={assetName}"}
 
         else{return ""}
 
This basically returns a value of "1" to the variable vals if there is no data in the reuired fields and the if statement will only return the URL if vals is empty ie contains no errors. If any of the fields are empty, the URL returned is "". (I did try using an 'OR' statement but this started misbehaving when I added more than about 5 'ORs')
 
The hyperlink in the popup was then configured to read the expression. If the fields were empty, the hyperlink returned is "" and it won't work. If there is data in all of the fields, the correct hyperlink is displayed.
 
The problem with this approach is that Field Maps was not referring to the asset attribute table when it encountered a field mapping instruction in the URL. field:GIS_ID={GIS_ID} would return "{GIS_ID}" as the value and this would appear in the Survey123 form. This happened fro all the parameters being passed in this way. MapViewer had no such problems, the URL would work as it should.
 
So I'm back to square one. I need a way of hiding/surfacing URLs in the popup based on the presence/absence of data in the required fields.
 
Any help received is much appreciated.

 

0 Kudos
1 Reply
ChristopherCounsell
MVP Regular Contributor

Yes. You can use  'inline' in the popup. Put an expression to return inline if field=value, which will cause the html link to appear or not. Here's an example:

https://community.esri.com/t5/arcgis-online-questions/hyperlink-within-expression-of-pop-up-in-agol/...

And here's another example where {expression/expr1} is your expression to return 'inline' if a field is true:

<div style="display:{expression/expr1};"><a href="arcgis-survey123://?itemID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&parameters>Text goes here

</a>

</div>