Skip to main content

Functions

RevOps Functions provides you with the flexibility to write custom TypeScript code to handle any business logic you can imagine. The power of TypeScript allows for complete customization to validate your business requirements and RevOps will effortlessly handle your deployment and execution. This guide provides detailed instructions on how to implement this functionality effectively.

Functions are able to utilize data from the relevant RevOps deal or use the RevOps SDK to fetch data from external systems, giving you the ability to combine the power of all of your systems with RevOps.

Guides

Function Types

Basic Function Example

A RevOps function is a named JavaScript/TypeScript function that is provided deal data and returns a list of errors or warnings to the submitting user.

export const validateDealBeforeSubmission = (data: PreSubmitTestData): PreSubmitResponse => {
const errors: PreSubmitResponse = [];

const paymentMethod = data.deal.terms.find(term => term.name === "Payment Method") as OptionTerm | undefined
const paymentTerms = data.deal.terms.find(term => term.name === "Payment Terms") as OptionTerm | undefined

if (paymentMethod?.value === "credit-card" && paymentTerms?.value !== "1") {
errors.push({ message: "Credit Card payments must be Due Upon Receipt" })
}

return errors;
}

In the submission validation example above, the function ensures the comparability of two separate terms. Any deals that are set to charge via Credit Card and required to use Due Upon Receipt payment terms. The sales rep must then decide if they want to change the payment method or payment terms to continue to submission.

Demonstration of validation flow and successfully correcting the error

TypeScript/JavaScript Resources

RevOps executes functions using a standard JavaScript evaluation engine with full TypeScript compatibility. This is a well supported language with a wide variety of documentation and resources on how to learn and write JS/TS. We've included links to some external resources we recommend to help you.

Exception Handling

Exception handling is the responsibility of the function author. When using types properly, the editor will highlight areas that might need edge case handling. Authors should use best practices such as null coalescing, guard clauses, and try/catch blocks.

Individual function types will include more information on controlling what happens with a function does fail.

Debugging

The Functions editor includes a section to test the result of your function based on a saved deal. The tester will show you the impact your function would have and allow you to inspect the data passed to the function. Output from console.log , console.warn , and console.error is automatically captured and made available to you.

Limitations

For security and performance reasons, certain limitations are placed on the execution of the function.

  • Functions are executed in a secured sandbox environment. The function has no access to make network requests (API calls) or to interact with any file I/O.
  • The function must execute in under 10 seconds. Most functions take only a few hundred milliseconds. This limit applies to an individual function execution and the combined execution of a function type.
  • Logs may be truncated if they are significantly over the average. Reasonable usage is not expected to hit this.

Total Number of Functions

We recommended combining functions whenever reasonable and grouping business logic together. The performance of your experience will slow down as you increase the number of functions of the same type. Most organizations use under 3-5 per type. The exact impact will vary based on a variety of factors and the performance impact may be worth the benefit. RevOps will only the total execution time per function type as noted in the limitations section.