I've been handed a web map that includes Arcade logic to build a link to launch survey 123 (in a browser) from a feature's popup. Arcade is a bit of blind spot for me, so I am hoping I can get some feedback concerning if 200.6 has the necessary parsing and expression handling to evaluate this script (below).
Thank you in advance!
(all URLs and GUIDS have been modified to protect the innocent)
//query the survey layer to see if a survey exists using the UIC ID
var survey = FeatureSetByPortalItem(Portal('https://www.some_domain.com/portal'),'3a9166a153ab451666715815d606904f',0, ['uic_id', 'globalid'])
var id = Text($feature.uicid)
var query = "uic_id = " +  "'"+ id + "'"
Console(query)
var result = Filter(survey, query)
//if there is a matching survey, send a link to edit, otherwise send a link to a new survey
if(Count(result)>= 1) {
 
    var edit_link = "https://survey123.arcgis.com/share/7b1aeio44a204416b819a60ad3e4c8b4?portalUrl=https://www.some_domain.com/portal&"
    var globalId ="mode=edit&globalId=" + StandardizeGuid((First(result).globalid),'digits-hyphen')
    var full_edit_link = edit_link + globalId
    var edit_link_expression = '<a>A survey for this UIC ID already exists</a><br><a href="' +full_edit_link + '">Edit Existing Survey</a>' 
    return {
      "type": "text",
      "text": edit_link_expression    
    }
} 
else 
{
    var link = "https://survey123.arcgis.com/share/7b1aeio44a204416b819a60ad3e4c8b4?portalUrl=https://www.some_domain.com/portal"
    var uicId = "&field:uic_id=" + $feature.uicid 
    var siteAdd ="&field:site_address=" + $feature.siteAddress 
    var deqId = "&field:deq_id=" + $feature.DEQID 
    var unitId = "&field:unit_id=" + $feature.unitID 
    var hansenProjNumber = "&field:hansen_project_number=" + $feature.projectNumber
    //get location
    var location = "&location=" +Geometry($feature).Y +"," +Geometry($feature).X
    var fullLink = link + uicId + siteAdd + deqId + unitId + hansenProjNumber +location
    var link_expression = '<a>Create a new Survey</a><br><a href="' +fullLink + '">Launch Survey123</a>'
     return {
        "type": "text",
        "text": link_expression
    }
}
Solved! Go to Solution.
I believe this should work, I don't see anything in the script that can't be handled by Arcade Evaluation support in native SDKs. Did you run into any issue?
I believe this should work, I don't see anything in the script that can't be handled by Arcade Evaluation support in native SDKs. Did you run into any issue?
I haven't attempted to implement it yet... was more inquiring about obvious red flags before going through the process of building this out. Appreciate your feedback!