Forms > Calculated Expressions - Is my arcade expression wrong?

920
5
04-13-2022 02:44 PM
Lindsay
Occasional Contributor

Hi there Field Maps community,

I am using the newly released calculated expressions in my forms. I want to calculate Ha so it shows in the pop-up and also writes into the table. My basemap is NZTM.

I'm having some issues though. My results are inconsistent. Sometimes it works, sometimes it doesn't. I am basic level arcade, so it could be that I haven't written the expression correctly. Whenever I test either expression in the Arcade Expression pop-out, the result shows correctly. I've used two different expressions so far. Sometimes it works for others, but not me. I have tried:

  • using different expressions to get the same answer
  • going incognito
  • getting someone else to test

It is inconsistent in the sense that the isempty expression worked for another user, then I tried it, and it worked for a day, now it doesn't populate anymore.

I reverted back to my original expression, and then it started to work (it hadn't worked before), but after a day, it stopped working.

Is there a best way to write this expression so it always works, is there something corrupt in my web map or is there a bug in the form?

These are the expressions I've been using.

 

 

if (IsEmpty(Geometry($feature))){
return;
}
else{
return round(Area($feature, 'hectares'),2)
}

 

 

 

 

 

Round($feature["Shape__Area"]/10000,2)

 

 

If there are any Field Maps developers watching the posts, I'd be happy to add you to a group to test my web map directly. This web map then gets embedded into an Experience Builder and the end user uses the Edit widget to add a feature.

Another question I have is, should I always be able to preview the calculation when I'm filling in the form? Sometimes I can see it, sometimes I can't(but it outputs correctly), other times it just doesn't calculate.

Thanks in advance for your help.

5 Replies
Lindsay
Occasional Contributor

I've tried recreating the issue in a separate, fresh map.This is a new error I hadn't received until today, so a week behind the other errors. The issue likely derives from what Arcade runs on and that I am trying to work in NZTM.

Execution Error:Cannot create Geometry in this SpatialReference. Engine is using a different spatial reference.

0 Kudos
by Anonymous User
Not applicable

Execution Error:Cannot create Geometry in this SpatialReference. Engine is using a different spatial reference.

@Lindsay   This is a known issue that we've addressed in our daily builds and will be available in our Early Access release at the end of the month, and then with our full release in June.

It happens if your feature layer and the map have different spatial references.

Lindsay
Occasional Contributor

Ok. Thanks for the quick reply Aaron. I should go back into ArcPro and double check the feature layer is in NZTM before I republish?

So I'm on top of when the releases happen, is there an email list that notifies us or do I need to follow all of you on Twitter....?

0 Kudos
by Anonymous User
Not applicable

Usually the basemap spatial reference determines the spatial reference of the map. So if you are using a basemap with Web Mercator, then you should publish your layer in Web Mercator (at least to workaround this bug).

We usually post an announcement blog post or link to a blog post in this forum. You can also follow Jeff Shaner on Twitter, he usually posts stuff when we release there.

Lindsay
Occasional Contributor

Hi @Anonymous User , I've checked the original feature class I published from and the map spatial coordinates. They were both NZTM. I'm not sure what I'm doing wrong, but I can't wait until June for the new release. My other question is will I need to rebuild my layers then that have this issue currently or will they automatically take in the change.