Select to view content in your preferred language

Arcade: How do I find the first empty field?

493
1
05-29-2022 06:15 AM
neomapper
Frequent Contributor

How do I get the variable loopResults to find the first empty field and return it back to the stages variable for id:0, labeled Engineering? When I load the script, loopResults always returns project_designed if it's not empty

var Project_Design = Date($datapoint["Project_Designed"])
var PA_Sent = Date($datapoint["PA_Sent"])
var PA_Recvd = Date($datapoint["PA_Recvd"])

var loopResults = When(!IsEmpty(Project_Design), Project_Design,
					   !IsEmpty(PA_Sent), PA_Sent,
					   !IsEmpty(PA_Recvd), PA_Recvd,'')

var stages = [
    {
        id: 0,
        label: "Engineering",
        completionDate: loopResults,
        threshold: 60
    },
	{
        id: 1,
        label: "CSR",
        completionDate: $datapoint["App_to_Processing"],
        threshold: 60
    },{
        id: 2,
        label: "Operations",
        completionDate: $datapoint["To_Operations"],
        threshold: 5*60
    },{
        id: 3,
        label: "Construction",
        completionDate: $datapoint["To_Construction"],
        threshold: 22*60
    },{
        id: 4,
        label: "Done",
        completionDate: $datapoint["PA_Recvd"],
        threshold: null
    }
];

 

0 Kudos
1 Reply
JohannesLindner
MVP Frequent Contributor

How do I get the variable loopResults to find the first empty field

You're currently looking for !IsEmpty(), so it returns the value of the first non-empty field. Remove the bangs:

var loopResults = When(IsEmpty(Project_Design), Project_Design,
                       IsEmpty(PA_Sent), PA_Sent,
                       IsEmpty(PA_Recvd), PA_Recvd,
                       '')

 


Have a great day!
Johannes
0 Kudos