Open crazymovingco opened 5 years ago
This is a case error. This script builds the constructor method from the item's type adding as
as a prefix and Item
as a suffix as seen below:
var itemTypeConstructorName = snakeCaseToCamelCase("AS_" + item.getType().toString() + "_ITEM");
The problem is that the itemType for date-time is DATETIME
and not DATE_TIME
so snakeCaseToCamelCase()
returns asDatetimeItem()
instead of asDateTimeItem()
(with a capital T)
See the form API reference for item.
Here's how I fixed it:
// Downcast items to access type-specific properties
var typeString = item.getType().toString();
if(typeString==='DATETIME') typeString='DATE_TIME' // handle the corner case of DATETIME
var itemTypeConstructorName = snakeCaseToCamelCase("AS_" + typeString + "_ITEM");
var typedItem = item[itemTypeConstructorName]();
Why is running the appscript giving this error?