Select to view content in your preferred language

Removing ; from the start of output for Attribute Rule

490
2
Jump to solution
10-31-2023 02:59 PM
Boomer1187
Emerging Contributor

Hi there,

I am trying to edit my attribute rule to remove the ';' that is produced at the start of my result.

I am attempting to ensure that whenever a new Project A polygon is created, that the project_number field for any intersecting polygons from Project B is populated for the project_number field in Project A. This includes when multiple projects from Project B are intersecting with Project A. It works with the logic, but the output produces a ; at the beginning of the output.

The attribute rule I've applied to my Projects_A class is producing an output like the below: 

Projects: ; PP-2023-1234; PP-2023-2345

--

var projB = Intersects(FeatureSetByName($datastore, 'Projects_B', ['project_number']), $feature)

var proj_nums

for (var projB_row in projB) {
proj_nums = proj_nums + ';' + ' ' + projB_row.project_number
}
return proj_nums

Is there a way to alter the above to ensure that the ; is removed from the resulting output start, and only in the middle to separate multiple project_numbers?

0 Kudos
1 Solution

Accepted Solutions
TedHoward2
Esri Contributor

Try using an array to collect your values and then use Concatenate

var proj_nums = []

for (var projB_row in projB) {
    Push(proj_nums, projB_row.project_number)
}
return Concatenate(proj_nums, "; ")

View solution in original post

0 Kudos
2 Replies
TedHoward2
Esri Contributor

Try using an array to collect your values and then use Concatenate

var proj_nums = []

for (var projB_row in projB) {
    Push(proj_nums, projB_row.project_number)
}
return Concatenate(proj_nums, "; ")
0 Kudos
Boomer1187
Emerging Contributor

Thanks so much @TedHoward2 - that worked perfectly!

0 Kudos