Arcade Calculation for Creating ID when add new record getting cleared out in Edit mode in Experience Builder

856
0
05-28-2023 09:09 AM
Labels (1)
LeilaJackson1
Occasional Contributor III

Hi -

I am using the below code to generate the year as part of an ID that I am creating in an AGO Map Viewer Form and pulling into Experience Builder. The ID has the following structure: {PR_PROJYEAR} - SW{PR_PROJNUM}. The current year should be generated using the below code, and Project Number created using a separate script, and they they are concatenated to create the ID. This is functioning in Map Viewer as expected when I add a new feature, and is maintained when I edit a feature. In Experience Builder, the ID is generated as expected when I add a new feature, but when I edit a feature, the Project Year, Project Number, and ID  are all wiped out. Is this a bug? Or can you tell me what I am doing wrong in the below code? 

Thanks!

 

 

//Generates Project Year based upon the year the nomination is added

// Define the edit context so the value is only calculated when the feature is created 
if ($editContext.editType == "INSERT") { 

//returns the current year
var timestam = Today()
var currentyear = Year(timestam)
 
return currentyear;

//keeps the current value if record is being updated only

} else if ($editContext.editType == "UPDATE") {

return $feature.PR_PROJYEAR

}

 

0 Kudos
0 Replies