Select to view content in your preferred language

is there an expression to differentiate SELECT vs ADD in arcade expression?

611
3
Jump to solution
09-05-2023 09:56 AM
WilsonLee
Occasional Contributor

in Field Maps Arcade Expression, how can I differentiate between "selecting an existing point" and "adding a new point" within an Arcade expression.

I'm trying to apply a  different code based on the action selected by a user (SELECT vs ADD) from a same layer.

currently, i have setup 2 layers in field maps for "Updating" and "adding a new point", but would like to combine them and make it more convenient for user. 

 

thanks,

Wilson

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
JustinReynolds
Regular Contributor

@WilsonLee 

Hello,

I believe what you are looking for is the edit context/edit type.  It is a profile variable found in the Form Calculation and Form Constraint Arcade Profiles

https://developers.arcgis.com/arcade/profiles/form-calculation/

https://developers.arcgis.com/arcade/profiles/form-constraint/

JustinReynolds_0-1693933991054.png

Your Add is INSERT and your select is UPDATE.

// Example usage of $editcontext.editType

if ($editcontext.editType == 'UPDATE') {        
    if (!IsEmpty($originalFeature)) {
        var oSelf = $originalFeature.rsrc_previous_feature_info;
        var oServiceNumber = $originalFeature.service_number;
        if (oServiceNumber == serviceNumber) {return oSelf};
    };
};

 

- Justin Reynolds, PE

View solution in original post

3 Replies
JustinReynolds
Regular Contributor

@WilsonLee 

Hello,

I believe what you are looking for is the edit context/edit type.  It is a profile variable found in the Form Calculation and Form Constraint Arcade Profiles

https://developers.arcgis.com/arcade/profiles/form-calculation/

https://developers.arcgis.com/arcade/profiles/form-constraint/

JustinReynolds_0-1693933991054.png

Your Add is INSERT and your select is UPDATE.

// Example usage of $editcontext.editType

if ($editcontext.editType == 'UPDATE') {        
    if (!IsEmpty($originalFeature)) {
        var oSelf = $originalFeature.rsrc_previous_feature_info;
        var oServiceNumber = $originalFeature.service_number;
        if (oServiceNumber == serviceNumber) {return oSelf};
    };
};

 

- Justin Reynolds, PE
WilsonLee
Occasional Contributor

Thanks Justin!!! let me try to update my codes🙏

0 Kudos
WilsonLee
Occasional Contributor

THANKS again! it works!!