Issues with pulling Survey 123 connect html tag styling into reports

620
3
03-07-2023 09:04 AM
ChristopherDawe
New Contributor III

I am having an issue pulling through the correct Survey questions in the correct format in to my report. In my survey I have html styling in various places including field names, choice lists, calculations etc to show text in the survey in a certain manner to aid the users visually.

This may be so that certain questions calculate a note field to change the colour of the answer or formatting in bold/italic etc, examples below

  • to calculate a field called ${rating}, in the calculate field I have: if${score}>6,'<b><font color="green">GOOD CONDITION</font></b>','<b><font color="red">POOR CONDITION</font></b>'} which would produce 
    • GOOD CONDITION or POOR CONDITION
  • in a select_mulitple choice list for ${species} I have: otter as the name and <b>Otter</b> (<i>Lutra lutra</i>) as the label which would produce...
    • Otter (Lutra lutra)

The survey reads this syntax fine and shows up as expected within the survey app, and additionally when using the feature layer in ArcGIS Pro or AGOL webmaps it appears as expected. The problem occurs when I use ${rating} in a report, it doesn't recognise the syntax and pulls through the whole text string including the html tags. Similarly when using the ${species} in a report it does the same and lists the full strings of all species including the html tags. I assume this is due to the full string including the html tags being stored as the actual attribute value in the table.

I have tried using the following in the report as a workaround for the ${rating} but it doesn't appear to work, presumably due to the mixed single and double quotes for the text colour.

  • ${if rating=='<b><font color="green">GOOD CONDITION</font></b>}GOOD CONDITION${/}${if rating=='<b><font color="red">POOR CONDITION</font></b>}POOR CONDITION${/}

I am aware that for the ${species} I could use something like the below, but with a huge amount of species in that one list (and multiple other lists with similar issues) it would become very unwieldy to have to put in an IF function for each and work out some way of having a separator between each value as well

  • ${if species=='otter'}Otter (Lutra lutra)${/} 

The workaround I have at the moment for one of the issues is to pass the ${rating} into another hidden field which removes the html tags and just stored the text in a question called ${rating2}, then use that in the report so the plain value comes through and can be styled in there using something like the following steps

  1. ${rating2}...calculation field ...if(${rating}='<b><font color="green">GOOD CONDITION</font></b>,'GOOD CONDITION','POOR CONDITION')
  2. then in the report use...${if rating2=='GOOD CONDITION'}GOOD CONDITION${/}${if rating2=='POOR CONDITION'}POOR CONDITION${/}

Due to my survey having 25 different variants of the ${rating} field I now have 25 hidden fields unless I want one master final rating field, but then the if function in the calculation for that would have to contain a nested if function for all of those 25 fields!

Any assistance would be massively appreciated, i am fairly new to using html styling inside survey 123 connect so if there is a better or more suitable way of getting the desired output I'm all for it!

EDIT:

In addition to the above I have a separate survey where in the survey I have a species list with the common name and then the Latin name in italic so in the choices list it is written as "Field Maple <i>Acer campestre</i>" and then displays in the survey as "Field Maple Acer campestre". when using Survey 123 feature reports this pulls through the HTML and doesn't resolve it to display in italic. I am using a separate csv with well over 1000 species in a select_one question in a repeat so cant see how I would ensure that the styling is pulled through into the report in a sensible manner

 

@IsmaelChivite @Katie_Clark @JamesTedrick 

0 Kudos
3 Replies
Katie_Clark
MVP Regular Contributor

Are the HTML tags in the label, name, or both? Assuming they're only in the label, would it work to just retrieve the name for the report?

Best,
Katie


“The goal is not simply to ‘work hard, play hard.’ The goal is to make our work and our play indistinguishable.”
- Simon Sinek
0 Kudos
ChristopherDawe
New Contributor III

They are in both label and name for the choice question. I have thought about limiting it to just the label but then we would need to manually edit the reports after they are produced anyway to get the Latin name in italic. 

 

With the calculation question it just uses the output of the calculation which includes the html.

I have been looking into the new "report builder for ArcGIS online" as it looks like this would honour the HTML but then that means having a separate reporting tool and it doesn't have the power automate functionality

Thanks

Chris

 

 

 

 

0 Kudos
Katie_Clark
MVP Regular Contributor

Sounds like your best bet might be to have hidden questions in the survey that populate with the values that you want in the report. (i.e. a separate hidden field for scientific name vs. common name). 

Best,
Katie


“The goal is not simply to ‘work hard, play hard.’ The goal is to make our work and our play indistinguishable.”
- Simon Sinek
0 Kudos