Add developer doc examples from #se_team_code_share#53
Open
mmeesseman wants to merge 4 commits intov2from
Open
Add developer doc examples from #se_team_code_share#53mmeesseman wants to merge 4 commits intov2from
mmeesseman wants to merge 4 commits intov2from
Conversation
This document provides an example of enforcing a daily sync requirement for mobile users using LOADRECORDS. It outlines the setup and code needed to ensure users sync their devices before collecting data.
This document provides an example of how to prevent users from creating more repeatable entries than allowed based on a choice field value. It includes code snippets demonstrating the use of event listeners and validation.
Added documentation for helper functions to display human-readable field values in PDF reports, including usage examples for top-level fields and repeatable sections.
This document provides an example of using a Fulcrum App Extension to visualize field data with Chart.js. It details the setup, code implementation, and offline usage instructions.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds four new developer documentation examples demonstrating Fulcrum Data Events, Report Builder helpers, and App Extensions patterns sourced from #se_team_code_share.
Changes:
- Added Report Builder helper functions for rendering display labels/values in EJS PDF reports (including repeatables and complex field types).
- Added two Data Events examples: limiting repeatable entry counts and enforcing daily sync via a “heartbeat” Task queried with
LOADRECORDS. - Added an App Extension example that renders a Chart.js visualization in an HTML attachment and writes results back to the record via
onMessage.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| docs/REPORT BUILDER/reports-examples/display-field-value-labels.md | New Report Builder example with helper functions to show human-readable labels/values in PDFs. |
| docs/DATA EVENTS/data-events-examples/prevent-creating-duplicate-repeatables.md | New Data Event example limiting repeatable entries and demonstrating OFF() cleanup. |
| docs/DATA EVENTS/data-events-examples/enforce-daily-sync-with-loadrecords.md | New Data Event example locking down forms until a daily sync is detected via Tasks + LOADRECORDS. |
| docs/App Extensions/app-extension-examples/visualize-data-with-chart-js.md | New App Extension example opening offline HTML to render a Chart.js bar chart and returning a result to the record. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+36
to
+40
| function getValue(dataName) { | ||
| return record.formValues.find(dataName) | ||
| ? record.formValues.find(dataName).displayValue | ||
| : ''; | ||
| } |
Comment on lines
+47
to
+49
| // CHOICEVALUE($visit_type) returns the selected choice value as a string (e.g. "1", "2"). | ||
| // If the entry number exceeds the allowed count, block it. | ||
| if (REPEATABLENUMBER() > parseInt(CHOICEVALUE($visit_type))) { |
| // REPEATABLENUMBER() returns the 1-based index of the current entry. | ||
| // CHOICEVALUE($visit_type) returns the selected choice value as a string (e.g. "1", "2"). | ||
| // If the entry number exceeds the allowed count, block it. | ||
| if (REPEATABLENUMBER() > parseInt(CHOICEVALUE($visit_type))) { |
Comment on lines
+97
to
+112
| if (taskDate === todayStr) { | ||
| // Device has synced today — allow the user to proceed | ||
| ALERT('All clear', 'Your data is up to date. You may proceed.'); | ||
| } else { | ||
| // Task date doesn't match today — device needs to sync | ||
| ALERT( | ||
| 'Sync Required', | ||
| `Please close Fulcrum and sync your device before continuing. ` + | ||
| `Last sync date: ${taskDate}. Today: ${todayStr}.` | ||
| ); | ||
|
|
||
| // Hide all fields to prevent data entry until synced | ||
| DATANAMES().forEach(function(dataName) { | ||
| SETHIDDEN(dataName, true); | ||
| }); | ||
| } |
Comment on lines
+143
to
+145
| // Ignore messages that don't contain our expected data shape | ||
| if (!event.data || !event.data.surveyDate) return; | ||
|
|
Comment on lines
+162
to
+167
| function renderChart(data) { | ||
| const ctx = document.getElementById('surveyChart').getContext('2d'); | ||
|
|
||
| new Chart(ctx, { | ||
| type: 'bar', | ||
| data: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds 4 new developer documentation examples sourced from the internal
#se_team_code_shareSlack channel. All examples have been cleaned up, customer PII and API tokens scrubbed, code formatted, and comments added for clarity.New files
Data Events
enforce-daily-sync-with-loadrecords.md— Uses a recurring Fulcrum Task as a daily "heartbeat" to block form access until the device has synced. UsesSTORAGE(),LOADRECORDS(),DATANAMES(),SETHIDDEN(), andINVALID(). (Credit: Jared Carey)prevent-creating-duplicate-repeatables.md— Limits repeatable entries based on a parent choice field value. DemonstratesREPEATABLENUMBER(),CHOICEVALUE(), and proper use ofOFF()for event listener cleanup. (Credit: Kyle Pennell)Report Builder
display-field-value-labels.md— Helper functionsgetValue()andgetRepValue()for rendering human-readable display values instead of raw stored values in EJS PDF reports. Handles ChoiceField, AddressField, SignatureField, and plain value fields. (Credit: Mike Meesseman)App Extensions
visualize-data-with-chart-js.md— Full example showing how to open an HTML App Extension that renders a Chart.js bar chart from form field data, with aonMessagecallback to write a result back to the record. Includes the complete HTML file inline and a note on offline bundling. (Credit: Emmanuel Benjamin)