Select to view content in your preferred language

Arcade in Field Maps vs. Map Viewer

188
3
02-10-2025 11:33 AM
ZachBodenner
MVP Regular Contributor

Hello,

Has anyone ever come across documentation on the differences in Arcade code evaluation between a map viewer popup and that same popup in field maps? 

As an example, I have an Arcade code snippet that functions perfectly fine in map viewer, Experience Builder, etc, but when I click on the feature in Field Maps, I get the red warning triangle and the following error message:

Expression Name:

Expression Title: Task History

Error Domain: com.esri.arcgis.runtime.error Error Code: 15 Error Description: Invalid call., Object failed to load, unable to execute task.

Based simply on the types of functions included, this code is very very similar to other code I've used that runs fine in Field Maps. Unfortunately the error message is a little unhelpful, doesn't provide a function or a line or anything. I want to track down some information on the differences in Arcade use between Field Maps and other applications.

Happy mapping,
- Zach
0 Kudos
3 Replies
ChrisDunn1
Esri Contributor

Hi @ZachBodenner ,

While there is no specific documentation, one helpful place to look is the Arcade Version Matrix. Field Maps is currently using version 100.15 of the Maps SDK, so it only supports Arcade functions through version 1.19, so if your code includes functions from a later version that would explain the error. Field Maps is currently being re-written on the 200 version of the Maps SDK, there is no specific release date yet but you can join the Tech Preview to test out the new version, including more up-to-date Arcade support. More details are available in the "What's Coming in 2025" section of this announcement: https://www.esri.com/arcgis-blog/products/field-maps/field-mobility/whats-new-in-arcgis-field-maps-n...

Chris

0 Kudos
ZachBodenner
MVP Regular Contributor

A great resource, thank you! Unfortunately it doesn't solve my current issue, as the functions I'm using are all fairly old (filter, orderby, featuresetbyname, text, and a for loop). I don't know how much troubleshooting you can help me with, but I'll leave the code here just in case.  I know Field Maps can be a bit finnicky compared to the map viewer; as an example, once I got this same error when I had created an array that was like ['thing 1','thing 2','thing 3',]. Map viewer didn't mind, but Field Maps really hated that trailing comma after 'thing 3'. Maybe there's something similar that I'm missing.

 

// Format table html
var tStyle = `<table style="width:100%;background-color:#f4f4f4;">`
var trpt1 = `<tr><td style="border-bottom: 1px solid #cccccc;border-right: 1px solid #cccccc;width:50%;padding-left:2%"><b>`
var trpt2 = `</b></td><td style="border-bottom: 1px solid #cccccc;border-right: 1px solid #cccccc;width:50%;padding-left:2%">`
var trpt3 = `</td></tr>`
var endTable = `</table>`

// Set variables. First variable is the unique ID that is shared by the primary and related data. Second variable is calling the related forms as a FeatureSet 
// Convert tree number to text to match Elements DB
var treeGlobal = text($feature.TreeNumber)
//var treeGlobal = text(24413)
var relatedForms = FeatureSetByName($map, "All Tree Tasks")
console("Num. Tree Tasks: "+count(relatedForms))

//create a filter statement where the maintenance form GUID = the Tree Inventory GlobalID
var filterStatement = "GISAssetNo = @treeGlobal"

//a maintenance form equals the table run through the filter
var inspForm = Filter(relatedForms, filterStatement)
console ("Inspection Form: "+inspForm)

// Sort related features by oldest to newest
var relatedDataSorted = OrderBy(inspForm, 'ActualEndDate DESC')
var filterStatement2 = "ActualEndDate <> null"
var closedTasks = filter(relatedDataSorted,filterStatement2)

var c = count(relatedDataSorted)
var c2 = count(closedTasks)
console ("Count of relatedDatsorted: "+c)
console ("Count of relatedDatsorted: "+c2)


var returnString
// If there are tasks in the task table, iterate through
if (c2>0) {

  var backgroundColor = "#7fa99c" 
  // Begin final return string by setting the header and opening the table
  returnString = `<p style="font-size:18px;margin-bottom:8px"><strong>Elements Task History</strong></p>`;
  
  // Build the pop-up string by iterating through all related features. Add or subtract new lines in the popupString as needed from the related form.
  for (var f in relatedDataSorted){
    // FILTER OUT OPEN TASKS - If there is no Acutal End Date, don't return that array item
    if (isEmpty(f.ActualEndDate)){returnString+=''}

    // Else, establish variables and fill out popup table
    else if (!isEmpty(f.ActualEndDate)){

      var taskLink = `<a href="https://elements.edenprairie.org/App/WorkManagement/ServiceOrders/Default_WM_ServiceOrders_Task_EditForm.aspx?dep=1&rel_mode=6&r=${f.taskID}"target="_blank"style="color: #000000">${f.taskID}</a>`
      var taskID = IIF(IsEmpty(f.TaskID),'',`${trpt1}Task ID${trpt2}${taskLink}${trpt3}`)
      var taskType = IIF(IsEmpty(f.TaskType),'',`${trpt1}Maintenance Performed (Task Type)${trpt2}${f.TaskType}${trpt3}`)
      var compBy = IIF(f.CompledBy!='','',`${trpt1}Completed By${trpt2}${f.CompledBy}${trpt3}`)
      var priority = IIF(IsEmpty(f.Priority),'',`${trpt1}Priority${trpt2}${f.Priority}${trpt3}`)
      var status = IIF(IsEmpty(f.Status),'',`${trpt1}Status${trpt2}${f.Status}${trpt3}`)
      var problem = IIF(IsEmpty(f.Problem),'',`${trpt1}Problem${trpt2}${f.Problem}${trpt3}`)
      var condition = IIF(IsEmpty(f.Condition),'',`${trpt1}Conditoin${trpt2}${f.Condition}${trpt3}`)
      var dbh = IIF(IsEmpty(f.DBH),'',`${trpt1}DBH${trpt2}${f.DBH}${trpt3}`)
      var remove = IIF(IsEmpty(f.RemovalNeeded),'',`${trpt1}Removal Needed?${trpt2}${f.RemovalNeeded}${trpt3}`)
      var chem = IIF(IsEmpty(f.Chemical_Treatment),'',`${trpt1}Chemical Treatent${trpt2}${f.Chemical_Treatment}${trpt3}`)
      var chemQty = IIF(IsEmpty(f.Chemical_Qty_ML),'',`${trpt1}Chemical Quantity (ml)${trpt2}${f.Chemical_Qty_ML}${trpt3}`)
      var perfBy = IIF(IsEmpty(f.Performed_By),'',`${trpt1}Performed By${trpt2}${f.Performed_By}${trpt3}`)
      var cont = IIF(IsEmpty(f.ContractorRemoval),'',`${trpt1}Contractor Removal?${trpt2}${f.ContractorRemoval}${trpt3}`)
      var contName = IIF(IsEmpty(f.Contractor),'',`${trpt1}Contractor Name${trpt2}${f.Contractor}${trpt3}`)
      var locates = IIF(IsEmpty(f.Locates),'',`${trpt1}Locates${trpt2}${f.Locates}${trpt3}`)
      var seeding = IIF(IsEmpty(f.Seeding),'',`${trpt1}Seeding${trpt2}${f.Seeding}${trpt3}`)
      var hole = IIF(IsEmpty(f.HoleDug),'',`${trpt1}Hole Dug${trpt2}${f.HoleDug}${trpt3}`)
      var notes = IIF(IsEmpty(f.Notes),'',`${trpt1}Notes${trpt2}${f.Notes}${trpt3}`)                          

      returnString += 
          `<h3 style="background-color:${backgroundColor};padding-left:2%">${Text(f.ActualEndDate, 'MMMM DD, Y')}</h3>
          ${tStyle} 
          ${taskType}${taskID}${compBy}${priority}${status}${problem}${condition}${dbh}${remove}${chem}${chemQty}${perfBy}${cont}${contName}${locates}${seeding}${hole}${notes}
          ${endTable}` 
    }        
  }
}
else {
  returnString= `<p style="font-size:18px;margin-bottom:8px"><strong>No Elements Tasks So Far</strong></p>`
}

return { 
	type : 'text', 
	text : `${returnString}`
}

 

Happy mapping,
- Zach
0 Kudos
ChrisDunn1
Esri Contributor

Hey @ZachBodenner  - nothing jumps out to me right away, but one thing I would try first is commenting out your Console() commands. I think I've seen examples where those can unexpectedly mess things up in Field Maps at times.

0 Kudos