=JSONFIFO
The =JSONFIFO() function appends a new JSON object to an existing JSON array while optionally enforcing a maximum array length. When a maximum length is set and exceeded, the oldest entry (first in the array) is automatically removed, maintaining a First-In-First-Out (FIFO) structure.
Syntax
Section titled “Syntax”=JSONFIFO(ExistingJsonArray; NewJsonObjectToAdd; MaximumLength)Parameters
Section titled “Parameters”-
ExistingJsonArray
- A JSON array to which a new object will be added.
-
NewJsonObjectToAdd
- A valid JSON object to append to the array.
-
MaximumLength
-
The maximum number of objects allowed in the array.
-
Use 0 to indicate no maximum limit.
-
How It Works
Section titled “How It Works”-
The new JSON object is appended to the end of the array.
-
If the array size exceeds MaximumLength, the oldest object is removed.
-
If MaximumLength is 0, the array grows without restriction.
Usage Notes
Section titled “Usage Notes”-
Ideal for rolling logs, audit trails, recent activity feeds, and history tracking.
-
Automatically manages array size without additional logic.
-
Formula function names are case sensitive and must be written in ALL CAPS.
Examples
Section titled “Examples”Scenario: Activity Log Tracker
Section titled “Scenario: Activity Log Tracker”Let’s say you’re maintaining an activity log that should only keep the 3 most recent entries.
Initial Setup
Section titled “Initial Setup”// Starting with an existing array of 2 activitiesExistingArray = [ {"timestamp": "2025-05-30 09:00", "action": "login", "user": "john_doe"}, {"timestamp": "2025-05-30 09:15", "action": "file_upload", "user": "jane_smith"}]Adding a New Entry
Section titled “Adding a New Entry”// Create new activity objectNewActivity = {"timestamp": "2025-05-30 09:30", "action": "report_generated", "user": "mike_wilson"}
// Add to array with maximum of 3 entries=JSONFIFO(ExistingArray; NewActivity; 3)Result
Section titled “Result”[ {"timestamp": "2025-05-30 09:00", "action": "login", "user": "john_doe"}, {"timestamp": "2025-05-30 09:15", "action": "file_upload", "user": "jane_smith"}, {"timestamp": "2025-05-30 09:30", "action": "report_generated", "user": "mike_wilson"}]Adding Another Entry (Triggers FIFO Behavior)
Section titled “Adding Another Entry (Triggers FIFO Behavior)”// Add a 4th entry - this will remove the oldest (first) entryNewActivity2 = {"timestamp": "2025-05-30 09:45", "action": "logout", "user": "john_doe"}
=JSONFIFO([previous result]; NewActivity2; 3)Final Result
Section titled “Final Result”[ {"timestamp": "2025-05-30 09:15", "action": "file_upload", "user": "jane_smith"}, {"timestamp": "2025-05-30 09:30", "action": "report_generated", "user": "mike_wilson"}, {"timestamp": "2025-05-30 09:45", "action": "logout", "user": "john_doe"}]Other Use Cases
Section titled “Other Use Cases”No Maximum Limit
Section titled “No Maximum Limit”// Set maximum to 0 for unlimited entries=JSONFIFO(ProductArray; {"item": "new_product", "price": 29.99}; 0)Single Entry Queue
Section titled “Single Entry Queue”// Keep only the most recent entry=JSONFIFO(StatusArray; {"status": "current"}; 1)Keywords
Section titled “Keywords”JSONFIFO, JSON array management, FIFO queue, rolling log, activity history, JSON append, workflow logging, formula function