new RequestHelpers()

Helper methods for HTTPS requests

Description

Provides methods for making HTTP requests and handling API interactions.

Inheritance: Utils → FulcrumHelpers → RequestHelpers

Extended by: DataEventHelpers

Inherited Methods:

  • All Utils utility methods (see Utils documentation)
  • All FulcrumHelpers Fulcrum-specific methods (see FulcrumHelpers documentation)

Methods Defined in This Class: Only HTTP request-related methods are documented below.

Members


requestAppRecords

Description

Description placeholder

Parameters
Name Type Attributes Default Description
query string
callback function <optional>
opt * <optional>
Returns

requestRecById

Description

Description placeholder

Parameters
Name Type Attributes Default Description
appId string

fulcrum app id

qflds string <optional>
''

fields to pull in request

recIDs Array.<string>

array or _record_id to request

callback function

callback

opt * <optional>

option for callback

Returns
Examples
function enterDisturbanceAreaTypeCallback(rows,dn){
   var output = rows.map(x => x.disturbance_area_type)
   SETVALUE(dn,output.join(', '))
}

var opt = 'disturbance_area_types'

M.requestRecById(appId,qflds,recIDs,enterDisturbanceAreaTypeCallback,opt)

Description

Description placeholder

Parameters
Name Type Description
rows Array.<{_record_id: string}>

rows

opt *

data name of field to enter record links into

Returns

updateRecord

Description

Description placeholder

Parameters
Name Type Attributes Default Description
recID string

_record_id to get

record *
callback function

callback to modify properties of existing record

index number <optional>

index of current record. If being called from array.

end number <optional>

index of last record in array of records. If being called from array.

complete string <optional>
''

Text for alert message when this.updateRecord is complete

Returns

getRecord

Description

Description placeholder

Parameters
Name Type Attributes Default Description
recID string

_record_id to get

callback function <optional>

callback is used by M.updateRecord

index number <optional>

index of current record. If being called from array.

end number <optional>

index of last record in array of records. If being called from array.

complete string <optional>
''

Text for alert message when this.updateRecord is complete

Returns

Methods


checkConnection( error )

Description

Description placeholder

Parameters
Name Type Description
error *

devUnhide( event ) → {void}

Developer Unhide

Description

Sets all fields visible if USERROLE() == 'Owner'

Parameters
Name Type Description
event *
Returns
Details

devEdit( event ) → {void}

Developer Edit

Description

Sets all fields editable if USERROLE() == 'Owner'

Parameters
Name Type Description
event *
Returns
Details

setAllRO( [ bol [, exc [, sec ] ] ] ) → {void}

Set All Read-only

Description

Sets all fields to readonly or editable or default, except those in the exclude list or not in the section if specified.

Parameters
Name Type Attributes Default Description
bol boolean <optional>
false

Set field to readonly, null sets to default.

exc Array.<string> <optional>

Array of datanames to exclude

sec string <optional>
''

Restrict function to only data names in this section

Returns
Details

isMerjentEmail() → {boolean}

Description

Checks if current user email ends in'merjent.com'

Returns
Details

disableLocationEdit( event ) → {void}

Description

Disable editing location

Parameters
Name Type Description
event *
Returns
Details

userInit() → {string}

User Initials

Description

Gets current users initials

Returns
Details

getReportIDvars( [ reportDate ] ) → {Object}

Get Report ID Variables

Description

Get information pieces used to build report id

Parameters
Name Type Attributes Default Description
reportDate string <optional>
Returns
Details

photoLandscape( event ) → {boolean}

Require photo to be taken landscape

Description

Validation for photo orientation, must be called from an ONCHANGE event of a photo field.

Parameters
Name Type Description
event *
Returns
Details

photoSetLoc( event ) → {void}

Photo Set Location

Description

Sets record location to the location of the first photo taken

Parameters
Name Type Description
event *
Returns
Details

clearRLAutoPops( event ) → {void}

Clear Record-Link Auto-populates

Description

If the value of the record-link field is null, on change, this data event will clear all of the auto-populate fields.

Parameters
Name Type Description
event *
Returns
Examples
ON('change', 'project_name', clearRLAutoPops)
Details

popLatLon( [ dn ] ) → {string}

Populate Latitude Longitude

Description

For use in data event. Sets value of {data_name} to current lat/lon as a string "lat,lon". Alerts if no GPS info.

Parameters
Name Type Attributes Default Description
dn string <optional>

output field data name to write to

Returns
Details

photoCheck4Caps( dn ) → {boolean}

Photo Check for Captions

Description

Checks photofield for photos without a caption. Returns an Alert.

Parameters
Name Type Description
dn string
Returns
Details

photoCheckCapLen( dn, max ) → {void}

Photo Check Caption Length

Description

Description placeholder

Parameters
Name Type Description
dn string
max number
Returns
Details

makeDnsRow( dns [, exc ] ) → {Object}

Make data_names Row

Description

Creates an object from a list of data names. Excludes Labels, Sections and HyperlinkFields.

Parameters
Name Type Attributes Default Description
dns *
exc Array.<string> <optional>
[]
Returns
Details

dns2Row


makeRepRows( repeatableDn [, exc ] ) → {Array.<Object>}

Make Repeatable Rows

Description

Converts a repeatable to an Array of Objects. Input repeatable data name.

Parameters
Name Type Attributes Default Description
repeatableDn string
exc Array.<string> <optional>
[]
Returns
Details

rep2Rows


rows2Summary( rows [, exc ] ) → {Array.<string>}

Rows to Summary

Description

Converts an array of objects to an array of summary strings, excluding specified keys. Each summary string lists key-value pairs separated by commas.

Parameters
Name Type Attributes Default Description
rows Array.<Object>

Array of objects to summarize.

exc Array.<string> <optional>
[]

Array of keys to exclude from summary.

Returns
Details

fv2DnRows( rows, dict ) → {Array.<Object>}

Form Values to Data Names Rows

Description

Converts an array of Fulcrum rows to an array of objects with data names as keys. Uses a dictionary to map form_value keys to data names.

Parameters
Name Type Description
rows Array.<Object>

Array of Fulcrum record objects.

dict Object

Dictionary mapping form_value keys to data names.

Returns
  • Array of objects with mapped keys and values.
Details

loadRecords( arr, formID, callback ) → {void}

Load Records

Description

Wrapper function for LOADRECORDS() expression.

Parameters
Name Type Description
arr Array.<string>
formID string
callback function

function to process records and store them to a variable or field. Callback must have one parameter for records. See example.

Returns
Examples
processRecordsCallback(records){
  loadedRecords = convertFV2DN(records,loadedFvs)
  var out = []
  for(const record of loadedRecords){
    var add = record.scientific_name + ' - ' + record.common_name
    out.push(add)
  }
  SETVALUE('result',out.join('\n'))
}

M.loadRecords(recIDs,appID,processRecordsCallback)
Details

getRepDn( dn ) → {string}

Get Repeatable Parent

Description

get parent data_name for a field. Returns only the next parent that is a repeatable.

Parameters
Name Type Description
dn string
Returns
  • data_name of the parent (repeatable or section) of a field. If there is no parent, it returns null.
Examples
getRepDn('inspector_name') // returns 'background'
Details

repParent? digParent? - make generic recursion function that produces row of all parents and parent types. For repeatables, secctions or elements of form schema.


digElement( el, collector ) → {void}

Dig Element

Description

Recursively collects all data_name:form_value pairs from element. Adds element to collector array. Primarily used as a sub-function within makeFvDict.

Parameters
Name Type Description
el Object

The parent element to start from.

collector object

The object to collect elements into.

Returns
  • Adds element to collector array
Details

makeFvDict( form ) → {Object}

Make Form Values Dictionary

Description

Input a fulcrum form schema Object and returns a dictionary object of {data_name:form_value}.

Parameters
Name Type Description
form Object

Fulcrum form schema object.

Returns
  • Dictionary of {data_name:form_value}.
Details

mkLocalFvDict( el ) → {Object}

Make Local Form Values Dictionary

Description

Creates a local dictionary of {form_value:data_name} for fields within the specified element or the entire form if no element is provided.

Parameters
Name Type Default Description
el Object | null

Fulcrum form element object. If null, uses the entire form.

Returns
  • Dictionary of {form_value:data_name}.
Details

repeatable2jrows( repDn [, exc ] ) → {Array.<Object>}

Repeatable to JSON Rows

Description

Converts a repeatable field's value into an array of objects with data names as keys.

Parameters
Name Type Attributes Default Description
repDn string

Data name of the repeatable field.

exc Array.<string> <optional>
[]

Array of data names to exclude.

Returns
  • Array of objects representing each row in the repeatable.
Details

loadForm( formID, callback ) → {void}

Description

Description placeholder

Parameters
Name Type Description
formID string

fulcrum form id

callback function

function to process form schema

Returns
Examples
processFormCallback(form){
    loadedFvs = M.flipKVpair(this.makeFvDict(form))
 }

M.loadForm(formID,processFormCallback)
Details

eachSecDn( secDn, callback ) → {void}

Each Section Data Name

Description

Performs callback function on each data name in a section.

Parameters
Name Type Description
secDn string

Section data name.

callback function

Function to perform for each data name.

Returns
Details

clear( dn ) → {void}

Description

Clears value in fulcrum field.

Parameters
Name Type Description
dn string

Data name to clear.

Returns
Details

getRepeatableValues( repVals, dnFv ) → {Object}

Description

Description placeholder

Parameters
Name Type Description
repVals *

this is from VALUE(repeatable data name)

dnFv string
Returns
Details

getNestedRepeatable( parentDn, childDn, dnFv ) → {Object}

Description

Description placeholder

Parameters
Name Type Description
parentDn string
childDn string
dnFv string
Returns
Details

deprecate or add recursion


timedProcessingMsg( time ) → {void}

Timed Processing Message

Description

block input into form with an alert message for a set time in milliseconds.

Parameters
Name Type Description
time number

milliseconds for settimeout

Returns
Details

add example


valProcessingMsg( dn, time ) → {void}

Value Processing Message

Description

block input into form with an alert message until a value is present in the specified data name or until a settimeout.

Parameters
Name Type Description
dn string
time number

milliseconds for settimeout

Returns
Details

mkPhotoDirHandler( photoFldDn [, photoDirDn [, photoCardDn [, secondary ] ] ] ) → {PhotoDirHandler}

Description

Factory method for PhotoDirHandler (backward compatibility)

Parameters
Name Type Attributes Default Description
photoFldDn string

Photo field data name

photoDirDn string <optional>
""

Direction field data name (degrees)

photoCardDn string <optional>
""

Cardinal direction field data name

secondary boolean <optional>
false

Use 16-point compass if true, 8-point if false

Returns

PhotoDirHandler instance

Examples
const photoDirObj = M.mkPhotoDirHandler('photo_field', 'direction_deg', 'direction_cardinal')
function changeDir(event){
  photoDirObj.popOther(event)
}
ON('change', photoDirObj.dnDir, changeDir)
ON('change', photoDirObj.dnCard, changeDir)
ON('add-photo', photoDirObj.photoDn, photoDirObj.extractPhotoDir)
Details

mkMLoadRecords( formID, enterLoadedData [, fulcrumHelpers ] ) → {MLoadRecords}

Description

Factory method for MLoadRecords (backward compatibility)

Parameters
Name Type Attributes Default Description
formID string

Fulcrum form ID

enterLoadedData function

Callback function to process loaded records

fulcrumHelpers FulcrumHelpers <optional>
this

Optional helper instance (defaults to current FulcrumHelpers instance)

Returns

MLoadRecords instance

Examples
const appID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

function processRecords() {
  const loadedRecords = loader.appRecords
  const titleList = loadedRecords.map(x => x.scientific_name + ' - ' + x.common_name)
  SETVALUE('result', titleList.join('\n'))
}

const loader = M.mkMLoadRecords(appID, processRecords)

ON('load-record', loader.getAppFvs)
ON('change', 'species_link', loader.loadRecords)
Details