Select to view content in your preferred language

autoIncrement not working in ArcGIS Pro field calculate

195
3
08-14-2024 07:17 AM
tbearb
by
Regular Contributor

After we upgraded to ArcGIS Pro version 3.3.1 we are no longer able to run the autoIncrement script to populate values in a field calculate. Attached is the error we're seeing where it is referencing a function was not found. Has anyone come across this issue?

rec=0 
def autoIncrement(): 
 global rec 
 pStart = 1  
 pInterval = 1 
 if (rec == 0):  
  rec = pStart  
 else:  
  rec += pInterval  
 return rec

tbearb_0-1723644912235.png

 

0 Kudos
3 Replies
JoshuaBixby
MVP Esteemed Contributor

If you ignore the error and hit Apply/OK, does it work correctly?  It might be a validation defect for the expression rather than an actual error in the expression.

0 Kudos
tbearb
by
Regular Contributor

So the odd thing is I hit Apply/OK and it would give an error saying I need to correct whatever is wrong before the calc can take place (that part seemed to be new in 3.3.1 - I want to say in the past versions it would let you click Apply/OK). After a few times of doing that, I tried again and I was able to see it go through.

0 Kudos
RhettZufelt
MVP Notable Contributor

I believe it is trying to run a function named "WF-"=. which isn't defined and should be calling the autoIncrement function.

I think the FACILITYID = line should be autoIncrement() and the concatenation and zfill should be handled in the function/returns.

Not sure what version of Pro this is from, but in 3.1.3 it is SequentialNumber helper and the top line tells it what function to execute:

RhettZufelt_0-1724106267421.png

 

R_

 

0 Kudos