If(string-length(${leak_id} = 0), concat('<font color="green"><b>', ${location_name}, '</b>', '</font>'), '')
CASE 2 - Leak Found and Not Repaired
If(string-length(${leak_id} > 0) and string-length(${leak_repair_date}=0), concat('<font color="red"><b>', ${location_name}, ‘ – NEEDS REPAIR’,'</b>', '</font>'), '')
CASE 3 - Leak Repaired and Not Re-Checked
If(string-length(${leak_id}>0) and string-length(${leak_repair_date}>0) and string-length(leak_recheck_date}=0), concat('<font color="orange"><b>', ${location_name}, ‘ – NEEDS RE-CHECK’,'</b>', '</font>'), '')
CASE 4 - Leak Repaired and Re-Checked
If(string-length(${leak_id}>0) and string-length(${leak_repair_date}>0) and string-length(leak_recheck_date}>0), concat('<font color="blue"><b>', ${location_name}, ‘ – LEAK REPAIRED & RE-CHECKED’,'</b>', '</font>'),'')
So, putting this all together gives me:
If(string-length(${leak_id}=0) , concat('<font color="green"><b>', ${location_name}, '</b>', '</font>'), If(string-length(${leak_id}>0) and string-length(${leak_repair_date} =0), concat('<font color="red"><b>', ${location_name}, ‘ – NEEDS REPAIR’,'</b>', '</font>'), If(string-length(${leak_id}>0) and string-length(${leak_repair_date} >0) and string-length(leak_recheck_date=0), concat('<font color="orange"><b>', ${location_name}, ‘ – NEEDS RE-CHECK’,'</b>', '</font>'), If(string-length(${leak_id}>0) and string-length(${leak_repair_date} >0) and string-length(leak_recheck_date}>0) ,concat('<font color="blue"><b>', ${location_name}, ‘ – LEAK REPAIRED & RE-CHECKED’,'</b>', '</font>', ‘’)))))
Can I use nested if/then for instance name and if yes, what am I missing??
Thanks,
--gary
Hi @GaryBowles1,
Yes, nested if() statements work for instance name.
It looks like you have the closing bracket for the last if() statement in the wrong place for the false condition. In you singular example after the </font> there is a closing bracket, followed by the '' for final false condition. In your combined if() statements, there is no closing bracket after </font> meaning the '' are within the concat and there is no false condition for the final nested if().
I have not tested this but it should work (I also find it easier to break the if() statements out onto different lines for each condition, you can then move them all back onto one line when put back into XLSForm):
if(string-length(${leak_id}=0),
concat('<font color="green"><b>',${location_name},'</b>','</font>'),
if(string-length(${leak_id}>0) and string-length(${leak_repair_date} =0),
concat('<font color="red"><b>', ${location_name}, ‘ – NEEDS REPAIR’,'</b>', '</font>'),
if(string-length(${leak_id}>0) and string-length(${leak_repair_date} >0) and string-length(leak_recheck_date=0),
concat('<font color="orange"><b>', ${location_name}, ‘ – NEEDS RE-CHECK’,'</b>', '</font>'),
if(string-length(${leak_id}>0) and string-length(${leak_repair_date} >0) and string-length(leak_recheck_date}>0),
concat('<font color="blue"><b>', ${location_name}, ‘ – LEAK REPAIRED & RE-CHECKED’,'</b>', '</font>'),
'')
)
)
)
Regards,
Phil.
Phil,
Thanks for the help, I got the statement to convert in Connect:
if(string-length(${leak_id}=0), concat('<div style="font-weight:bold;color:green">',${location_name},' - NO LEAKS','</div>'), if(string-length(${leak_id}>0) and string-length(${leak_repair_date}=0), concat('<div style="font-weight:bold;color:red">', ${location_name}, ‘ – NEEDS REPAIR’,'</div>'), if(string-length(${leak_id}>0) and string-length(${leak_repair_date}>0) and string-length(${leak_recheck_date}=0), concat('<div style="font-weight:bold;color:orange">', ${location_name}, ‘ – NEEDS RE-CHECK’,'</div>'), if(string-length(${leak_id}>0) and string-length(${leak_repair_date}>0) and string-length(${leak_recheck_date}>0), concat('<div style="font-weight:bold;color:blue">', ${location_name}, ‘ – LEAK REPAIRED & RE-CHECKED’,'</div>'), ''))))
however it does not appear to be working:
There are 3 of the conditions in the nested if statement within the 4 surveys that are submitted.
Suggestions?
Thanks,
--gary
Hi @GaryBowles1,
Are you able to share the XLSForm (xlsx file and any media/scripts) and instructions on which questions to fill out to make the instance name work in each case.
I need to look into it further with your exact survey, as if you set up a simple instance name with if() statements it is working.
Regards,
Phil.
Phil,
Attached is the survey form and .csv file associated with barcode scan. I have been able to get this to work by using the boolean() and not(boolean()) functions instead of string-length(). I have also found that the html formatting (<div style>) as stated here: https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-quick-guide-to/ba-...
doesn't work and I have to use old reliable <font color="blue"><b> html formatting.
This is all being done to differentiate surveys in the Inbox. It would be great if we could set up multiple Inboxes instead. I have added this to the Ideas section.
Thanks,
--gary
Did you figure out how to get your whole statement working? I am having a similar issue where only part of the statement executes in the Inbox.
I see that there is a 3-line limit to the instance_name cell in XLS forms. My expression is on a single line. Do we know if there is also a character limit that will be read and executed in XLS? Such as 255?
Update - I've fixed my issue and verified that there is NOT a 255 character limit for the instance_name cell.