Introduction 

 

As a Flow Step, the Compute Formula service takes an Excel-style formula, computes it, and returns the resulting value to the selected field.  This facilitates many different types of data transformations and use cases, including date math, text replacement, and composite scoring, among many others. 

You can find the repository on Adobe Github 

 

Prerequisites 

 

To deploy and use the Compute Formula Flow Step Service you will need: 

  • Experience using a command line. 
  • Have git installed and have basic experience in its usage. 

 

Support 

 

While the Self-Service Flow Steps framework is fully supported, Compute Flow is an open-source application built on the framework using Adobe IO Runtime.  Issues specific to the Compute Flow application should be logged on the github repository or on nation.marketo.com.   

 

Deployment 

 

Clone the Repository 

 

In a command line, navigate to the folder where you want to clone the code from the Git Repository for AIO Compute Formula.  From there use the following command to clone to repo: 

 

git clone git@github.com:adobe/aio-compute-formula.git 

 

Obtain IO Runtime Credentials 

 

Make a new project in the Adobe Developer Console, selecting the “Project from Template” option: 

Kenny_Elkington_0-1695847025070.png

 

 

Select the App Builder Template and save your project: 

Kenny_Elkington_1-1695847025072.png

 

 

Select a workspace, either Production or Stage, that you want to deploy the application to and use the Download All option to download the credentials to the folder where you cloned the repository in the previous step: 

Kenny_Elkington_2-1695847025073.png

 

 

Once you’ve downloaded the file locally, from your command line use the following command to use the downloaded credentials for your application deployment: 

 

aio app use <file location> 

 

Kenny_Elkington_3-1695847025074.png

Render Manifest from Template 

 

Now you’ll need to use the render-manifest script to create a manifest yaml file including your desired API key (this is the API key which you will use later in the installation phase) and log level (info, warn, error, or debug).  Use the following command to render your manifest: 

npm run render-manifest <path:'./manifest.yml'> <apiKey> <logLevel> 

Kenny_Elkington_4-1695847025074.png

 

 

 

Install NPM Packages 

 

Now you will need to locally install the dependencies for this project using the following command in your command line: 

npm install 

Deploy Application and Obtain Service URL 

 

To deploy your application, use the following command: 

aio app deploy 

Once finished the command line will list out the endpoint URLs of the application.  Copy the URL ending in ‘serviceSwagger’ for use in the next step. 

Kenny_Elkington_5-1695847025075.png

 

 

Install and Configure Service 

 

In Marketo, navigate to the Admin->Service Providers menu and use the Add New Service button.  In the dialog box, enter the URL you copied from the previous section: 

Kenny_Elkington_6-1695847025075.png

 

 

Then follow the instructions for entering your API key: 

Kenny_Elkington_7-1695847025076.png

 

 

In the Incoming Fields section, select the fields which you want the service to be able to write data back to: 

Kenny_Elkington_8-1695847025077.png

 

 

 You can always come back to change the field mappings later if you are not sure about what fields you want to be eligible for writes at this time.  Follow the rest of the installation guide and then your service will be ready to use in Smart Campaigns 

Usage 

 

Flow Step Fields 

 

Formula 

 

The Formula field accepts Excel-style formulas, and supports all of the functions that are supported by FormulaJS.  Lookup and other column-related functions are not available.  Your formula should not include a leading = sign as you would when entering the formula in a cell of a spreadsheet application. 

While standalone mathematical statements are supported to some extent, complicated cases should be implemented as Excel functions, as some standard mathematical operators, like ^, have behaviors distinct from the mathematical operation that they represent outside of a JavaScript context. 

Strings embedded into the formula field, including tokens for string-like fields, e.g. dates, should be surrounded by quotation marks for functions to behave as they are expected to. 

Return String 

 

When returning a value to a string or string-like field, such as a Date or a Datetime, you should select the field you wish to return in the Return String field.  Each field configured as an inbound field for your service will be listed in this field*. 

Return Number 

 

When returning a value to a number-type field, like Integer, or Float, you should select the field you wish to return in the Return Number field.  Each field configured as an inbound field for your service will be listed in this field*. 

 

*If the picklist of either Return String or Return Number is empty, or does not include choices which were recently added, you should refresh your picklist choices, either via the refresh button on the flow step card or from the Admin->Service Providers menu. 

Example Use Cases 

 

Composite Scoring 

 

A common scoring use case is to create a weighted composite score from two or more other scores.  The Compute Formula Flow Step makes this simple to do.  For this example, you will use two source scores, Behavior Score and Demographic Score, and return the value to a field called Composite Score.  To build our formula, you need to decide how to weight the source scores.  Our hypothetical marketing organization values Behavior scores at 30% and Demographic scores at 100%.  Our formula would then look something like this*: 

 

SUM(PRODUCT({{lead.Behavior Score}}, 0.3), {{lead.Demographic Score}}) 

 

*When using numbers between -1 and 1 which have a decimal place, you will need to include a leading Zero (0) when embedding the number into your formula, e.g. 0.8. 

 

If a person record has a Behavior Score of 3 and a Demographic Score of 20, then the resulting composite score would be 20.9.  Scores in Marketo Engage are integers, however, so you should be sure to return a round number.  Use the ROUND() function to make the output an integer.  Now our Formula will look like this: 

 

ROUND(SUM(PRODUCT({{lead.Behavior Score}}, 0.3), {{lead.Demographic Score}})) 

 

Now that you’ve defined your formula, you’ll want to make sure that you’ve configured the fields which you want to write back to, in this case “Composite Score.”  Go to Admin->Service Providers, drill down into the service, and edit the Incoming Fields section to enable the Composite Score field.  Composite Score is a custom field for this example, so if you do not have this field in your instance, you’ll need to create a new one, or use a different score field. 

Kenny_Elkington_9-1695847025078.png

 

 

Now let’s put this into practice.  Since this is a composite score, in order for the score to be kept up to date, you need to listen for changes to the source scores to update the composite score when they change.  That means you need a triggered Smart Campaign with Data Value Changes Triggers for both Behavior Score and Demographic Score.   

Kenny_Elkington_10-1695847025079.png

 

 

Insert the flow step, populate your formula, and select your desired field to return to using the Return Number field.   

Kenny_Elkington_11-1695847025079.png

 

Now when you activate this campaign and a person’s Behavior Score changes, then your campaign will activate and return the result to your selected field. 

Kenny_Elkington_12-1695847025080.png

 

 

 

Kenny_Elkington_13-1695847025081.png

 

 

 

Date Differential/Time in Stage 

 

To measure the efficiency of marketing and sales funnels it is common to measure the amount of time that a person spends in a Marketing Stage.  In particular, the number of days a lead spends in the Marketing Qualified or Sales Qualified stages before the lead is acted upon is a significant indicator of how well aligned the marketing and sales processes are functioning.  While this information is easy to synthesize with a business intelligence application, bringing that same data into Marketo and acting upon it has required complicated API integrations to populate back to person records in Marketo.  With Compute Formula, the process is as simple as defining a formula and your return field.  The DAYS() function counts the number of days between and end date and a beginning date. 

 

DAYS(“{{lead.SQL Date}}”, “{{lead.MQL Date}}”) 

 

Kenny_Elkington_14-1695847025081.png

 

 

Kenny_Elkington_15-1695847025082.png

 

 

Round Robin Lead Assignment 

 

While Marketo provides Random Sample functionality to obtain a percentage-based sample of an audience, some Sales Owner assignment use cases benefit from more fine-grained control over lead assignment.  One example of this is to take the modulus (remainder) of a lead id, using the number of potential owners that you can assign leads to.  Suppose you have 55 potential lead owners, and you want to get an approximately even distribution of leads assigned to a given owner.  One of doing this is to assign each of your owners a number from 1 to 55, and then to take the modulus of the integer lead id.  Our formula would then look like this, where the Number is the lead ID, and the Divisor is the number of potential owners: 

 

MOD({{lead.id}}, 55) 

 

Given an id of 117, the resulting value would be 7. 

Our campaign flow would have a Compute Formula step with our formula, and Return Number set to a Sales Owner Seed field, followed by a Change Owner step configured with choices corresponding to each sales owner. 

Kenny_Elkington_16-1695847025083.png

 

 

Kenny_Elkington_17-1695847025083.png

 

 

Kenny_Elkington_18-1695847025085.png