Skip to content

Add developer doc examples from #se_team_code_share#53

Open
mmeesseman wants to merge 4 commits intov2from
se-team-code-share-examples
Open

Add developer doc examples from #se_team_code_share#53
mmeesseman wants to merge 4 commits intov2from
se-team-code-share-examples

Conversation

@mmeesseman
Copy link
Contributor

This PR adds 4 new developer documentation examples sourced from the internal #se_team_code_share Slack 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. Uses STORAGE(), LOADRECORDS(), DATANAMES(), SETHIDDEN(), and INVALID(). (Credit: Jared Carey)
    • prevent-creating-duplicate-repeatables.md — Limits repeatable entries based on a parent choice field value. Demonstrates REPEATABLENUMBER(), CHOICEVALUE(), and proper use of OFF() for event listener cleanup. (Credit: Kyle Pennell)
      Report Builder
  • display-field-value-labels.md — Helper functions getValue() and getRepValue() 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 a onMessage callback to write a result back to the record. Includes the complete HTML file inline and a note on offline bundling. (Credit: Emmanuel Benjamin)

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.
@mmeesseman mmeesseman requested a review from a team as a code owner March 19, 2026 15:44
Copilot AI review requested due to automatic review settings March 19, 2026 15:44
@mmeesseman mmeesseman requested a review from a team as a code owner March 19, 2026 15:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants