What Helper Functions can I Use?

Modified on Wed, 24 Apr 2024 at 02:47 PM

To make adding formulas a little easier, you have access to what we call "helper functions". When used, they can make writing expressions a little simpler for you. The helper functions as well as some examples have been outlined below.


To use the helper functions, you will need to use the expected syntax. Syntax is like the recipe for writing code. It tells you how to put the words or symbols together in the right order. 


Understanding what a helper function is used for and what it returns after running, will help you choose which helper function will work best. 


You can further take a look at some examples of how the helper functions are used. You may even be able to copy the example expressions to use in your forms!




SyntaxUsed ForExamples
addDays(days, fromDate)Calculating dates. Commonly used in the min or max property of the Date Component to block out dates from being selected or for displaying a warning message.A warning message to display when Reimbursement date is outside accepted date range:
newDate(dateComponentID) < addDays(-41, date)

Min Property will block out dates from the current date to 21 days out:

addDays(21)
and(value1, value2)Allowing an expression to consider two different options that must both evaluate to trueA group of fields should be visible if two fields are not marked as true.
and(!exemption, !notSubject)
The workflow will be sent to the Chief Admin Officer when the funding request is for professional development and the request is for curriculum materials.
and(development === 'Yes', materials === 'Yes')
concat(a, b, separator, 'fallback')Put together two values to display somewhere else.Display the employee's full name
concat(employeeFirst, employeeLast, ' ', 'Unknown')
currentPageIndex()When you have paginated your form, you can use this helper function to display the current page.Display the current page of total pages
`Page ${currentPageIndex() + 1} of ${pageCount()}`
currentStep()Used to identify the current step of the submission Tracking Steps in a workflow:
(()=>{
if (stepTracker?.includes(currentStep())) {
let newArray = [...stepTracker];
newArray.length = newArray.indexOf(currentStep()) + 1;
return newArray;
}
return [...stepTracker || '', currentStep()];
})()
Display action buttons for certain steps:
['adminAssistantStep'].includes(currentStep())
divide(a, b, 'fallback')Divide two numbersCalculating the FTE value:
divide(hours,40, '')

Determining the total amount that can be contributed to an HSA:

divide(computed1, input9)
equals(componentID, value)Determining if the values are equalDisplaying a section when a field is showing that the submitter is a minor: 
equals('Yes', isMinor)
Display a Group of fields when the form type is indicated to be for a New Hire:
equals(formType, 'New Hire')
fromCurrency(componentID)Removing the currency formatting from a value in order to perform calculationsSending to the Assistant Superintendent when the amount is greater than $5,000.
fromCurrency(amountToBePaid) > 5000
Calculate the total expenses for transportation:
toCurrency(fromCurrency(airTravel) + fromCurrency(baggageFees) + fromCurrency(rentalCar) + fromCurrency())
getAssignedTo()Get the name or email or object of name and email of the user assigned the submissionIn notifications to give the name of who the form is assigned to:
Hello ##getAssignedTo().name##
Apply a signature of the person assigned:
currentStep() === 'adminStep' ? getAssignedTo().name : value
getCell()Get the value from cells in a table rowCalculate the total miles from two table columns based on the odometer values:
getCell(endingOdometer) - getCell(beginningOdometer)
Calculating the hours worked based on start and stop times:
(Number(getCell(stopTime).substring(0,2))-Number(getCell(startTime).substring(0,2)) + ((Number(getCell(stopTime).substring(3,5))-Number(getCell(startTime).substring(3,5)))/60)).toFixed(2)
getCurrentRowIndex()Get the value of the indicated cell based on the row index starting at 0 for the first row. This is only available using the formula prop.Using two tables to gather information on the same subjects and linking the information in the second table to the first:
tableOneId[getCurrentRowIndex()].name
Adding a counter label to a table to identify rows by a number (1,2,3, etc.) without static rows:
getCurrentRowIndex()+1
getSequenceId()Get the sequence id for the submission to apply to an identifierCreating an identifier formula that uses the sequence id for each submission and starts with six 0s.
'#' + padStart(getSequenceId(), 6, '0')"
getSubmissionId()Get the id assigned to the submissionIn a startPacket object as the value for the id:
...{id: getSubmissionId()},...
getSubmittedBy()Get the name or email or object of name and email of the submitterAssign the start step to the submitter (as a dynamic assignee) for corrections:
getSubmittedBy()
Conditionally send a notification if the submitter is not the secretary
getSubmittedBy()?.email !== secretaryAssignment.email

includes(list, value)In a list of values, check if a value is includedDisplay a Group of fields if a selection (from a multi-selection option) includes any of the identified values:
includes(['1', '2', '3'], numberOfPositions)
Display a reject button on a certain step and if a radio value is a certain value:
currentStep().includes('approvalStep') && action1 === 'Request Revisions'
isBlank(componentID)Check if there is no value for a componentDisplay Reject Actions if a Radio selection has not been made or the selection identifies the submission should be rejected.
isBlank(rejectCorrect) || rejectCorrect === 'Reject'
Display a Spacer Component for visual purposes when there is no value yet in the identified component.
isBlank(leaveComponent)
isEmail()Check if the value is an emailUse the validate prop to ensure that the value entered is an email.
isEmail(value)
isEmail(recSubEmail)
isGreaterThan(num1, num2)Evaluate if one number is greater than anotherDisplay a Group of components when the identified component value is greater than a number.
isGreaterThan(numberOfDocumentsProvided, 2)
isGreaterThanOrEqualTo(num1, num2)Evaluate if one number is greater than or equal to another numberSkip a workflow step unless the value of a component is greater than or equal to an identified number
isGreaterThanOrEqualTo(expenseTotal, 5000)
isLessThan(num1, num2)Evaluate if one number is less than another numberUse the validate prop to ensure the value entered does not exceed or equal a certain value.
isLessThan(computed3)
isLessThanOrEqualTo(num1, num2)Evaluate if one number is less than or equal to another number
Use the validate prop to ensure the value entered does not exceed a certain value.
isLessThanOrEqualTo(advanceAmount, estimatedSum)

isNotBlank(componentID)Check if a component has a valueDisplay a Timestamp Component to capture the exact time a Signature has been added.
isNotBlank(signature1)
isOptional()Make a component optional (or not required)Use the validate prop to make a component option on the start step, but required on other steps.
currentStep() === 'start' ? isOptional() : isRequired(value)
isRequired(value)Make a component requiredUse the validate prop to make a component required when a field has a value, but optional if not.
authorize ? isRequired(value) : isOptional() 
multiply(a, b, 'fallback')Multiply two numbersCalculate the Total Earnings in a Timesheet
'$' + multiply((rate.split('$')[1]),totalHours, 0.00)
notEquals(componentID, value)Determine if two values are equalOnly display a group of fields when the selected value is NOT a specified value.
notEquals(hrAction, 'Change of Account Code')
now()Returns an ISO formatted datetime representing now: "yyyy-mm-ddThh:mm"Set the max value available as now.
now()
objectToOptions()Take an Object and create Options for a list component (Dropdown, Radio, Checkbox)Give conditional options based on a user input and by accessing a dataset:
objectToOptions(fundingSource === 'Step VII' ? stepVIIFundingCodes.project : fundingSource === 'Title Funding' ? titleFundingCodes.project[titleNum] : '')

Give options to choose a supervisor listed in a dataset:
objectToOptions(supervisors.District.map((p)=>p.name).sort())
optionsToObject()Take a list of options and create an ObjectCreate an object that combines the selected options from a Dropdown Component and a Checkbox component:
optionsToObject([...dropdown1, ...])
or(value1, value2)Allowing an expression to consider two different options where either could evaluate to true
Check whether one of two locations was selected from a list of Options.
or(location === 'Facilities', location === 'Transportation')

Display a group of components when at least one of two options are selected.
or(includes(medicalConcerns1, 'anaphylactic'), includes(medicalConcerns1, 'asthma'))
ordinal()Returns a string number with the ordinal suffix appended (st, nd, rd, th)Add the ordinal number for the date:
ordinal(newDate(date).toLocaleString('en-US', {day: 'numeric'}))"
padEnd(string, length, characters)Pads the string on the right side with the identified characters if it's shorter than the specified length.Create an Identifier that ends with the same numbers:
'#' + padEnd(getSequenceId(), 6, 1)
padStart(string, length, characters)Pads the string on the left side with the characters if it's shorter than the specified length.Create a PO # in an Identifier component that will use the sequence Id and be 6 characters.
'#' + padStart(getSequenceId(), 6, '0')
pageCount()If a form has been paginated, this helper function gives the total number of pages.Create a dynamic label displaying the current page against the total pages.
`Page ${currentPageIndex() + 1} of ${pageCount()}`
subtract(a, b, 'fallback')Subtract two numbers and optionally define a default value (fallback)Subtract the total allotted budget from the total expensed:
subtract((nonTravelDays * 50 + travelDays * 25), sum(breakfast, lunch, dinner))
Give the remaining balance:
subtract(sum(mileageTotalColumn),sum(accountAmount))
sum()Add numbersGive the total for the daily cost for either in-state or out-of-state travel:
sum(emplDaillyCost, studDailyCos) || sum(outStateDailyCost)
Calculate the total score based on 5 other input components:
sum(score1, score2, score3, score4, score5)
toCurrency()Adding the currency formatting to a value (often used after calculations)
Calculate the cost of buses for a field trip:
toCurrency((fromCurrency(inDistrictBusCost)) * Number(busesTotal))
Calculate the total cost for mileage:
toCurrency(getCell(miles) * perMile)
today()Evaluate today's dateSet the minimum available date for selection to today:
today()
Compare the date to show a message to the user about due dates:
new Date(today().split('-')[0],today().split('-')[1]-1,today().split('-')[2],7) < payrollCutoff.toString().split(' ').splice(1,3).join(' ') ? ('Must be approved by your supervisor and in the payroll office by: ' + compareCurrentDate + 'at 4pm') : 'The deadline for the submission has passed for this pay period. Your submission will be processed for next pay period.'
withinRange(value, min, max)Check that a value is between two numbersValidate the value entered is between two numbers:
withinRange(totalClaimedAllowances, 0, totalBasicPersonalAllowancesEntitled) || exempt


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article