Examples - fulcrumapp/fulcrum-core GitHub Wiki
List all of a form's fields by data_name, including repeatables
const { Client } = require('fulcrum-app');
const { Form } = require('fulcrum-core');
const client = new Client('shhh');
const formId = 'c5ddf8fd-0355-4841-8309-a3c151dd9026';
client.forms.find(formId)
.then((rawForm) => {
const form = new Form(rawForm);
Object.entries(form.elementsByDataName).forEach((entry) => {
console.log(`Data Name: ${entry[0]}, Key: ${entry[1].key}`);
});
});
/*
Data Name: park_name, Key: af72
Data Name: operator, Key: 483d
Data Name: type_of_facility, Key: cff4
Data Name: contact_info, Key: 6d7a
Data Name: address, Key: 0fd9
Data Name: operating_hours, Key: 6427
Data Name: park_features, Key: 4ccf
Data Name: park_name_1, Key: 3160
Data Name: feature_type, Key: f79c
Data Name: photos, Key: 0fe3
Data Name: status, Key: 4cf8
Data Name: issue_comment, Key: 335a
Data Name: park_photos, Key: 5dcd
*/
Like the above example with added cli prompting for your API key
and Form-id
using inquirer.js
// npm install fulcrum-app
// npm install fulcrum-core
// npm install inquirer
// paste this snippet into a file named `app.js` and run it like: `node app.js`
const { Client } = require('fulcrum-app');
const { Form } = require('fulcrum-core');
const inquirer = require('inquirer')
var questions = [{
type: 'password',
name: 'api',
message: "What's your api key?",
},{
type: 'input',
name: 'form-id',
message: "What's the form-id?",
}]
inquirer.prompt(questions).then(answers => {
const client = new Client(answers['api']);
const formId = answers['form-id'];
client.forms.find(formId)
.then((rawForm) => {
const form = new Form(rawForm);
Object.entries(form.elementsByDataName).forEach((entry) => {
console.log(`Data Name: ${entry[0]}, Key: ${entry[1].key}`);
});
});
});