Arcade accessing Fields from FeatureSet

773
1
Jump to solution
10-12-2022 08:13 PM
Labels (1)
MatthewHoare1
New Contributor II

Hi, 

Having issues with retrieving a field from a FeatureSet. Following other examples, referring the Field name as per below is supposed to work:

 

 

myFeature.job_wo
myFeature["job_wo"]

 

 

However I get a:

Execution Error:Runtime Error: Cannot call member property on object of this type. job_wo

The below is my code for reference:

 

 

var portal = Portal('https://linktomyportal/');
var completed_surveys = FeatureSetByPortalItem(
    portal,
    'portalobjectid',
    0,
    [
        'objectid',
        'job_wo'
    ],
    false
);
Console(completed_surveys.job_wo);

 

 

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

completed_surveys is a Featureset, a collection of features. You can only call the field name on single features.

So you have to extract a feature from the featureset. One way to do it:

var completed_surveys = ...

// just get the first feature
var survey = First(completed_surveys)

// we have to check that survey is not null, else we would produce an error
// by calling a member property of null
if(survey == null) {
    Console("survey is null -> completed_surveys is empty")
} else {
    Console(survey.job_wo)
}

Have a great day!
Johannes

View solution in original post

1 Reply
JohannesLindner
MVP Frequent Contributor

completed_surveys is a Featureset, a collection of features. You can only call the field name on single features.

So you have to extract a feature from the featureset. One way to do it:

var completed_surveys = ...

// just get the first feature
var survey = First(completed_surveys)

// we have to check that survey is not null, else we would produce an error
// by calling a member property of null
if(survey == null) {
    Console("survey is null -> completed_surveys is empty")
} else {
    Console(survey.job_wo)
}

Have a great day!
Johannes