No, I am storing JSON in a calculation field that gathers data from all required sources, and then just returns a JSON.stringify() statement at the end. It has to be inside of a try/catch block or it wonât save.
try {
JSON.stringify({
id: ï»ż@Record IDï»ż,
creation_date: @Creation Date,
status: @Status,
start_time: ï»ż@Start Timeï»ż != null ? moment(ï»ż@Start Timeï»ż).tz('America/New_York').format('YYYY-MM-DD[Z]HH:mm:ss') : null,
... etc., additional fields as required...
})
} catch (e) {
e // Will return the error message which is great for testing, but in production, you might consider returning a blank object if you're using this in other calc fields
}
Iâm still not sure if the below method is totally the best way to do this, but it works. When youâre fetching this JSON from another calc field, you have to go through an extra step to ensure that the JSON is parsed correctly, and not included if it doesnât. This way, you can get a final JSON object that actually contains related data.
var raw_entries = ï»ż@All of JSONï»ż; // Gathered from the first step above
var cleansed_entries = [];
for (var i = 0; i < raw_entries.length; i++) {
var entry = raw_entries[i];
try {
var obj = typeof entry === 'string' ? JSON.parse(entry) : entry;
cleansed_entries.push(obj);
} catch (e) {
// Skip malformed entry
}
}
// Example of sorting related items before installing
cleansed_entries.sort(function(a, b) {
return new Date(a.creation_date) - new Date(b.creation_date);
});
try {
JSON.stringify({
id: ï»ż@Record IDï»ż,
related_entries: cleansed_entries
})
} catch (e) {
e // Or blank object as per above
}
Once you have these fields in place, you can then just reference this field in another calc and use the raw JSON object (cleansed first, as per the above method) and convert it to HTML, markdown, or whatever format you need. AI is exceptionally helpful in doing this, particularly if you can feed it clear examples of what youâre looking for. ES6 Javascript is king and AI has it pretty much perfected.
PS: One of the main challenges doing this in Tape is the fact that you canât see a live preview using an actual item. Therefore, if you try to add these fields to an app with a LOT of records in them, it might cause issues if you have to save it multiple times. Also, itâs important to be aware that Tape calculation fields actually produce webhooks when they change, so if you have an automation that fires âon updateâ but it happens on any field, that flow will fire on items where the calc field has been updated and saved. Long story short, extreme caution is recommended.