Select to view content in your preferred language

Arcade expression

830
2
Jump to solution
01-16-2023 11:21 AM
MiltonVrolijk
Emerging Contributor

I want to create unique asset nr using Arcade expression to display the numbers and letters from domain field and a sequence number

for example

Road_type         → CR

Location              → 01

Sublocation        → 22

CR0122-0001

CR0117-0002

CR0251-0003

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Alum

Create a database sequence: Create Database Sequence (Data Management)—ArcGIS Pro | Documentation

Use this expression in the attribute rule:

// Calculation Attribute Rule for the ID field
// triggers: Insert, Update
// Exclude from application evaluation

// If there is already a value in the ID field, return that
if(!IsEmpty($feature.AssetNumber)) {
    return $feature.AssetNumber
}

// get all the parts for the unique id, format them correctly
var parts = [
    $feature.RoadType,
    Text($feature.Location, "00"),
    Text($feature.Sublocation, "00"),
    "-",
    Text(NextSequenceValue("NameOfTheSequence"), "0000")
]

// concatenate and return
return Concatenate(parts, "")

Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Alum

Create a database sequence: Create Database Sequence (Data Management)—ArcGIS Pro | Documentation

Use this expression in the attribute rule:

// Calculation Attribute Rule for the ID field
// triggers: Insert, Update
// Exclude from application evaluation

// If there is already a value in the ID field, return that
if(!IsEmpty($feature.AssetNumber)) {
    return $feature.AssetNumber
}

// get all the parts for the unique id, format them correctly
var parts = [
    $feature.RoadType,
    Text($feature.Location, "00"),
    Text($feature.Sublocation, "00"),
    "-",
    Text(NextSequenceValue("NameOfTheSequence"), "0000")
]

// concatenate and return
return Concatenate(parts, "")

Have a great day!
Johannes
MiltonVrolijk
Emerging Contributor

Thanks, Johanes

0 Kudos