// Check that EndDate exist, save as Date.
if(IsEmpty($record.approximateEnd)){
return null;
} else {
var MyDate = Split(Left($record.approximateEnd, 10),"-");
var MyTime = Right($record.approximateEnd, 13);
MyTime = Split(Left(MyTime, 8), ":");
MyDate = Date(MyDate[0], (MyDate[1]-1), MyDate[2], MyTime[0], MyTime[1], MyTime[2]);
}
// Check that EndDate is later than StartDate
if (MyDate>$record.Start_) {
return MyDate;
} else {
return null;
}
Solved! Go to Solution.
Hi Andreas!
There are two relevant Arcade functions that will likely be helpful here:
So in your example, you could use DefaultValue similarly:
// Set end date to null if the field does not exist.
var endDate = DefaultValue($record, "approximateEnd", null)
Hopefully these functions will give your arcade script the flexibility it needs to handle JSON with varying properties. Please let me know if you have any more questions regarding this.
Thank you,
Duncan
This code will check if the Feature or FeatureSet contains a field.
function fieldExists(item, fieldName) { //item can be a Feature or FeatureSet
var fields = Schema(item).fields;
for (var i in fields) {
if (Lower(fields[i].name) == Lower(fieldName)) return true;
}
return false;
}
iif(fieldExists($feature, "field_name"), "Field Exists", "Field doesn't exist");
Hi Andreas!
There are two relevant Arcade functions that will likely be helpful here:
So in your example, you could use DefaultValue similarly:
// Set end date to null if the field does not exist.
var endDate = DefaultValue($record, "approximateEnd", null)
Hopefully these functions will give your arcade script the flexibility it needs to handle JSON with varying properties. Please let me know if you have any more questions regarding this.
Thank you,
Duncan
Great, thanks a lot!