Can I hide HTML elements of my popup according to a variable?

1612
14
Jump to solution
05-03-2020 06:48 PM
MattCreaney
Occasional Contributor

I have a popup where custom URLs are displayed.  The URLs displayed are to pre-populate a Survey123 form based on known data outside of ArcGIS.  I have generated the html for the popup based on a spreadsheet that builds the HTML automatically.  The spreadsheet has data for all the features.  I want to hide/disable some of the URLs based on whether the URL is relevant to the feature that was selected.

I cannot simply load these values into the database because the data belongs to a related table and by uploading it to this table I would have duplicate entries once the Survey123 form is submitted.  If anyone has any better ideas, I would appreciate it.  I've played with Arcade and I can't figure out a good way to make this work.

0 Kudos
1 Solution

Accepted Solutions
DerrickWong
Esri Contributor

Hi Matt Creaney

You should probably use != -1 or >= 0  instead of == 1 or == 0. This should cover all cases.

Did that test hastily and so it was an oversight on my part. My bad.

I have updated the screenshot to reflect this.

I would appreciate if you can mark the answer as correct if it solved your issue; helps others quickly find the answer too 😃

Cheers

View solution in original post

14 Replies
DerrickWong
Esri Contributor

Hi Matt Creaney

You can add a hidden field in survey123 form, which acts as a flag.

Then using if(condition, a, b), you can set the URL to be blank if the flag is true/flase.

Alternatively, you can hide fields if they aren't suppose to show anything using the relevant column

Here's a link for more info.

https://community.esri.com/groups/survey123/blog/2016/05/28/the-art-of-hiding 

Hope that helps.

Derrick

0 Kudos
MattCreaney
Occasional Contributor

Hi Derrick

The pop up I’m trying to configure belongs to a table within my map. The URLs within the pop up link to Survey123 survey with prepopulated fields depending on the URL selected. Each URL is relevant to different features in the table, populating fields in Survey123 that are not attributes of the feature layer, they’re attributes of the not-yet-created sub feature. Does this make sense?

So the layer that the pop up belongs to is just a table of assets that have not yet been built. The layer being created in Survey123 is a check process during build where values are to be populated from the popup, values which are “planned” but might change during build.

0 Kudos
DerrickWong
Esri Contributor

Hi Matt Creaney

Ah ok. From what you are saying, you are trying to populate the form fields with respect to the selected feature, which then queries some external data?

If this external data can be queries by REST, perhaps you can consider pulling the required information using the PullData JS function?

https://proceedings.esri.com/library/userconf../devsummit19/papers/DevSummitPS_102.pdf 

What you would then do is pass in a unique value to your survey123 form, and have the javascript function query the relevant external URL and get the required information?

0 Kudos
MattCreaney
Occasional Contributor

Hi Derrick.

Thanks, I will read that.

I’ve tried uploading the CSV to my map but Arcade wouldn’t talk to it.

Get Outlook for iOS<https://aka.ms/o0ukef>

0 Kudos
DerrickWong
Esri Contributor

Matt Creaney

I was referring to querying the web external service from Survey123 via a JS function.

Reading from CSV will work too but it's not as dynamic (requires you to populate the csv and update it).

With the JS approach, it will pick up the changes for every new query.

I am assuming the end goal is for the user to see the populated fields in the survey123 form based on selected feature? i.e. does it matter what the URL what is displayed in the popup, or as long as the form populates the right fields?

0 Kudos
MattCreaney
Occasional Contributor

Yes, thanks - that is correct.

I’ve not used js in a popup before so I’ll look into it.

Uploading a csv to a map is not particularly an issue as there would only be 1 per map which would be part of the project setting up phase. Regardless, when I tried to use Arcade to find the value I couldn’t do it.

Get Outlook for iOS<https://aka.ms/o0ukef>

0 Kudos
DerrickWong
Esri Contributor

Matt Creaney

Just did a bit of testing.

This might be the quicker approach you were looking for, but it requires bit of 'hardcoding' of logic:

Modify / append the if/else statements to suit your needs.

0 Kudos
MattCreaney
Occasional Contributor

Hi Derrick

Thank you so much.  I tried this code and put the expression tag as the URL in the popup but it always returns null

0 Kudos
DerrickWong
Esri Contributor

Hi Matt Creaney

Just as a test, replace the whole expression with just:

return $feature["Asset_Name"]

and click on the blue "Test" button.

That should give you the asset name of a feature.

Then modify this line to show:

return Find (XXXX, $feature["Asset_Name"],  0 ) where XXXX is the value returned from the first test.

Does it return -1, 0  or some other value?

0 Kudos