arcade code problem: varying years

537
3
03-09-2023 08:05 AM
Labels (3)
SoleneMas
New Contributor II

Good morning,

I try to create a code with arcade, allowing to create a dat value according to several conditions.

I have a tree data that contains fields not_diag, periodicity, date_diag and maj_previsionnel which is the field where the value should appear.

if the not_diag field is not empty and the periodicity includes 1 then maj_previsionnel=date_diag +1 year

So make this condition on the four periodicity values.
I wrote the code this way below. The problem is that it doesn’t display anything, so I don’t know if it works or not.
HELP 😃

If($feature["note_diag"]!="" && $feature.periodicite=="1") {
return ($feature["maj_previsionnelle"])= Dateadd($feature["date_diag"],1,'years');
}
else{
If($feature["note_diag"]!="" && $feature.periodicite=="2") {
return (maj_previsionnelle)= Dateadd($feature["date_diag"],2,'years');
}
else{
If($feature["note_diag"]!="" && $feature.periodicite=="3") {
return ($feature["maj_previsionnelle"])= Dateadd($feature["date_diag"],3,'years');
}
else{
If($feature["note_diag"]!="" && $feature.periodicite=="4") {
return ($feature["maj_previsionnelle"])
= Dateadd($feature["date_diag"],4,'years');
}
}}}

 

Tags (2)
0 Kudos
3 Replies
DavidPike
MVP Frequent Contributor
if ($feature["note_diag"] != "" && $feature.periodicite == "1") {
return Dateadd($feature["date_diag"],1,'years')
}

else if($feature["note_diag"] != "" && $feature.periodicite == "2") {
return Dateadd($feature["date_diag"],2,'years')
}

else if($feature["note_diag"] != "" && $feature.periodicite == "3") {
return Dateadd($feature["date_diag"],3,'years')
}

else if($feature["note_diag"] != "" && $feature.periodicite == "4") {
return Dateadd($feature["date_diag"],4,'years')
}

//else {return something}
0 Kudos
SoleneMas
New Contributor II

Thank you for your offer.
However, no value appears either.
I eassaie to make it appear in the popup is the value is empty knowing that the fields are filled.

Also I wanted to use this technique for collector because we don’t have fieldmap yet, I have a big doubt that this is the right way to automatically propose a value in maj_previsional.

0 Kudos
DavidPike
MVP Frequent Contributor

What happens if you set this as the else

 

else {return $feature["date_diag"]}

 

what are you data types for periodicite? string or numbers?

0 Kudos