Select to view content in your preferred language

Arcade in AGOL for Symbology Classes with multiple criteria and a Domain value

476
3
Jump to solution
10-28-2024 10:26 AM
Labels (1)
Megan2
by
Occasional Contributor

I created a survey123 and am setting up the resulting point feature class in an AGOL map (which then feeds into an Experience Builder for easier use and data editing by non-GIS staff). 

In the survey, someone can request a variance permit. They will put in their requested start date of the permit, and the end date is auto-calculated and read only in the survey (start date + 21 days). The survey also contains hidden fields so that staff can later update the point data in the web map to include whether the application for the permit was Approved, Denied, or Pending (and this is a domain). 

I'm working to set up symbology into the following:
Approved, In Progress
Approved, Future
Approved, Expired
Denied
Needs Review

Each of the Approved ones are based on meeting certain requirements:
(approval_status = 'Approved' && starts on/before today && ends on/before(today+21)
(approval_status = 'Approved' && starts after today)
(approval_status = 'Approved' && ends before today)

Denied is based simply on approval_status = 'Denied'

Needs Review is based on approval_status = 'Pending' and being a catch all for empty values

Originally I defined:
var approved = $feature.approval_status = 'Approved'

However when I went to set up the symbology, the only option available to symbolize by was "Needs Review". We wondered if it was related to approval_status being a Domain value field, so we edited it to be as shown below, but now I get the output:

Test execution error: Execution error - Invalid parameter. Verify test data.

I went through the data and did update most of them to be Approved/Denied/Pending (I left a couple empty to make sure that would also get collected and symbolized but still getting that error message.

I'm super brand new to Arcade (aka this is day 2 or 3) but I like spreadsheets some so I'm slowly catching on to the commands and structure thanks to all the online resources and examples. I appreciate any guidance! 

 

// Applicant's requested start date and end date
var var_begin = $feature.start_date
var var_end = $feature.end_date
// Today and 21 days from today because permits last 21 days
var current_date = Today()
var current_end = DateAdd(Today(),21, 'days')
// Identifying when Approved vs Denied
var approved = DomainName($feature.approval_status, 'Approved')
var denied = DomainName($feature.approval_status, 'Denied')

// Approved and ending in the next 21 days means In Progress
// Approved and hasn't started yet means Future
// Approved and ended before today means Expired
// Denied means denied, regardless of date
// Pending, null, and anything else should fall under Needs Review
When(
  (approved && var_begin <= current_date && var_end <= current_end), 'Approved, In Progress',
  (approved && var_end > current_end), 'Approved, Future',
  (approved && var_end < current_date), 'Approved, Expired',
  (denied), 'Denied',
'Needs Review');

 

 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

The DomainName function requires the feature and the field, so you're making the variables Approved and Denied incorrectly. See if this works

// Applicant's requested start date and end date
var var_begin = $feature.start_date;
var var_end = $feature.end_date;
// Today and 21 days from today because permits last 21 days
var current_date = Today();
var current_end = DateAdd(Today(), 21, "days");
// Identifying when Approved vs Denied
var approval = DomainName($feature, "approval_status");

// Approved and ending in the next 21 days means In Progress
// Approved and hasn't started yet means Future
// Approved and ended before today means Expired
// Denied means denied, regardless of date
// Pending, null, and anything else should fall under Needs Review
When(
  approval == "Approved" && var_begin <= current_date && var_end <= current_end, "Approved, In Progress",
  approval == "Approved" && var_end > current_end, "Approved, Future",
  approval == "Approved" && var_end < current_date, "Approved, Expired",
  approval == "Denied", "Denied",
  "Needs Review"
);

 

 

View solution in original post

0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor

The DomainName function requires the feature and the field, so you're making the variables Approved and Denied incorrectly. See if this works

// Applicant's requested start date and end date
var var_begin = $feature.start_date;
var var_end = $feature.end_date;
// Today and 21 days from today because permits last 21 days
var current_date = Today();
var current_end = DateAdd(Today(), 21, "days");
// Identifying when Approved vs Denied
var approval = DomainName($feature, "approval_status");

// Approved and ending in the next 21 days means In Progress
// Approved and hasn't started yet means Future
// Approved and ended before today means Expired
// Denied means denied, regardless of date
// Pending, null, and anything else should fall under Needs Review
When(
  approval == "Approved" && var_begin <= current_date && var_end <= current_end, "Approved, In Progress",
  approval == "Approved" && var_end > current_end, "Approved, Future",
  approval == "Approved" && var_end < current_date, "Approved, Expired",
  approval == "Denied", "Denied",
  "Needs Review"
);

 

 

0 Kudos
Megan2
by
Occasional Contributor

You are both magnificent and speedy.

Okay, so I was wrong to try to define var approval down to the level of individual values. That definitely makes sense. I hadn't poked at any Domain tools yet within Arcade so I was unclear on the instructions a bit in what I read, but it looks like when written out, it should still be structured basically identical to what I originally had. That helps tremendously, thank you!

0 Kudos
KenBuja
MVP Esteemed Contributor

Glad to help.

One other thing. You should determine what happens when the var_end is equal to current_end, since that isn't covered and would result in "Needs Review"

0 Kudos