Select to view content in your preferred language

Retain FacilityID Value when Creating Records if Not Null

407
1
08-03-2023 01:55 PM
drWood
by
New Contributor III

Hello all,

I am trying to update my attribute rule for calculating object FacilityIDs to retain existing values of FacilityID when appending data rather than creating a new one each time. Any help would be much appreciated. I have tried using the IsEmpty function with no avail.

 

 

//Assign initial FacilityID value to variable FID
var IdSeq = NextSequenceValue("esSeq1")
var FID = "ES_" + text(Date(), "MMDDYYYY_") + IdSeq;

//Test first sequence value
if(IdSeq<=100010){
   return FID} 
else {IdSeq = NextSequenceValue("esSeq2");
      FID = "ES_" + text(Date(), "MMDDYYYY_") + IdSeq};

//Test second sequence value if necessary
if(IdSeq<=100010){
    return FID}
else {FID = "Update Attribute Rule";
return FID};

 

 

1 Reply
rzufelt
Occasional Contributor

Did you try Not is empty (!IsEmpty)?

The following will return the existing FacilityID if it exists, if not, moves on to the else block (assuming the FID field is named 'FacilityID').

if (!IsEmpty($feature.FacilityID)){
  return $feature.FacilityID
}
else{
  // get and assign new sequence here
}

 R_

0 Kudos