Select to view content in your preferred language

Field Maps Filter fonction not working using an intersect value

328
2
03-02-2026 09:33 AM
CristianGraf
Occasional Contributor

Hi Community!

I'm working on a project where half of the data it's intersected from a existing polygon (AKA Project Polygon). This polygon has the base data: project name, number, user, dates... So for any new data created on that specific polygon it will be transfered do the new collected ones.

This is very usefull for us, it's help us maintain a standard flow and it's helps to avoid any misspelling once on the field.

One of our goal it's to create a unique id filtered on the project number. So for any type of data, we will need a unique ID from 1 to X. 

Here's our code... and it's not returnig what we are specting. As we are intersecting the project number (no_proj) from another layer maybe the issue it's there and the filter it's not doing what it should.

Any guess or another wya to do it? 

 

var numberlist = FeatureSetByName($map,"2-Station d'inventaire")

// Return total list
function RecupererNoProjet(np_1) {
var EntreesDansProjet = Filter(numberlist, "no_proj = '" + np_1 + "'")
var max_feature = First(OrderBy(EntreesDansProjet, "id_table DESC"))
if(max_feature.id_table!= null) { return max_feature.id_table}

return 0;
}

//If value is empty
if(IsEmpty($feature["id_table"]) || ($feature["id_table"])==0 ){

var np_1= null

//Get project number
np_1=$feature["no_proj"]
//Get total project number
var num_proj = RecupererNoProjet(np_1);
return num_proj + 1
}
else {
//Return existing velue lor different to 0
return $feature["id_table"]
}
Thank you!!!
 
 
Cheers!
0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

Use the Console function to test whether you're getting back any results from the Filter function. Also, is the field "no_proj" a string field or numeric field? You can use variable substitution in the Filter function to avoid the quote problem

function RecupererNoProjet(np_1) {
  var EntreesDansProjet = Filter(numberlist, "no_proj = @NP_1");
  Console(Count(EntreesDansProjet));
  var max_feature = First(OrderBy(EntreesDansProjet, "id_table DESC"));
  if (max_feature.id_table != null) {
    return max_feature.id_table;
  }
  return 0;
}
0 Kudos
CristianGraf
Occasional Contributor

Hi KenBuja!

no_projet it's a text field. id it's a numeric integer one.

 

I will try it asap!

 

Thank you!!!

0 Kudos