Installing the Plug-In
You should have installed your Infusionsoft Pocket Developer plug-in using the instructions provided when you purchased the plug-in.
If, for any reason, you have not installed your Pocket Developer plug-in, follow these simple instructions, to learn how.
Pocket Developer
Field Math Plug-in TM
QuickStart Guide
The Field Math Plug-in gives you the following Infusionsoft superpowers:
- → Create counters, serial numbers, totals, avaerages, build custom reports, dashboards and more
- → Add, subtract, multiply or divide up to 52 fields or constants
- → Use any combination you like (e.g. (total Purchases/numPurchases)*10)
- → Place the result in the output field you specify
Two Ways to Use an API Guys Plug-inTM
1. In Campaign Builder, add an HTTP Post Snippet to a Sequence within a Campaign.
Doing this allows the Field Math Building Block script to run on each contact in the Campaign individually, as the contact moves through the Campaign.
2. Outside of Campaign Builder, save an Action Set using the Building Block’s POST URL.
This method allows the Field Math Building Block script to be run on lists of contacts.
Configuring the HTTP Post Snippet
1. Open an HTTP Post Snippet in a Sequence within your Campaign.
2. In the POST URL field, type :
http://yourdomain.com/scripts/PocketDeveloper/Blocks/FieldMath/fieldmath.php
3. Leave the default Name/Value Pair as contactID and ~Contact.Id~
4. Hover over the end of the first Name/Value Pair field to make the Add (+) and Delete (-) field symbols appear
5. Click the + to add a field
6. In the new fields, type formula in the Name field and type the formula you want the Field Math Building Block to perform in the Value field
For Your Reference:
- A formula can be simple or complex
- A formula can contain up to 52 different variables (a – z and A – Z)
- A formula can add (+), subtract (-), multiply (*) and divide (/) any of the variables
- By grouping variables within parentheses, formulas will follow the basic mathematical order of operations, also known as PEMDAS
- The variables will be assigned to Merge Fields or constants in the next step
- A formula CANNOT contain any spaces
- If your formula is complex, you may want to work it out on paper first
7. For each variable in your formula, you will add either a Merge Field or a constant
Obtain the field names by using the Merge button located on the right of the Post URL. Select the field name the drop down.
You can use any field in the Merge Field drop down that contains a number, including contact, company, owner and referral partner.
Merge Field Rules
- You must put a tilde (~) before and after the field name
- You must precede the field name with the table name and a period (.)
- You must precede a custom field name with an underscore ( _ )
- Custom field example for Company: ~Company._myCustomField~
- Constants can be any number, including whole numbers or decimals
When a Merge Field is a field name, the script will use the value it finds in that field for that contact
8. Add another Name/Value Pair field. In the Name field, type saveTo. In the Value field, add the merge field where you would like the results of your formula to be stored.
How To Configure Field Math In A Saved Action Set
To create a Saved Action Set to run in an individual record or on a list:
1. Go to the Infusionsoft Main Menu → CRM → Settings → Action Sets
2. Click the green “Add An Action Set” button
3. In the window that opens, give your Action Set a descriptive name, for example, “Field Math – Add One to Counter Field”, and select Send An HTTP Post To Another Server
4. Put the Field Math Building Block URL in the Post URL field, when it appears
- Notice that there are no field pairs to define in this dialog box. The only way to include instructions on what you want done is with the Field Math Block script
- Add the instructions (using the proper format) directly to the Post URL as a query string.
- A query string starts with “?” after the URL and includes the same key value pairs you created in the HTTP Post Snippet
- Each key value pair is separated from the next one in the query string by ( & ) and there is an ( = ) between each key and value
5. Save the Action Set
How To Construct A Post URL With Query String For A Saved Action Set
To send run Field Math, from an Action Set, exactly as we did from the HTTP Post Snippet in Campaign Builder, we would construct the query string as follows:
http://yourdomain.com/scripts/PocketDeveloper/Blocks/FieldMath/fieldmath.php?formula=((a+b)/c)*x&a=Contact._ArenaHandicap&b=Contact._ActivityLevel&c=Contact._HighestHandicapAchieved&saveTo=Contact._UmpireRating
This URL looks long and scary but don’t let that intimidate you. Query strings are pretty easy to decode once you know what you are looking at, and they are very useful.
This query string is color coded to make easier to pick out the component parts:
- The post url (black) is
http://yourdomain.com/scripts/PocketDeveloper/Blocks/FieldMath/fieldmath.php
- The formula is formula=((a+b)/c)*x
- The variables are
a=Contact._ArenaHandicap
b=Contact._ActivityLevel
c=Contact._HighestHandicapAchieved
x=10
(Note that field names do not have tildes around them, when you are constructing query strings for Action Sets)
- The saveTo field is saveTo=Contact._UmpireRating
- Each of these are called Key Value Pairs and they are separated by a &
Just as with our HTTP Post Snippet in the Campaign Builder, if this URL was run against Herb Jones’ record, using an Action Set, it would write the value 57.5 to Umpire Rating.
Demo Video
Use Field Math As A Counter
Pro Tip #1: Use Field Math As A Counter
How often have you needed a counter to increment each time something happens?
You can use Field Math to create a counter by simply incrementing the value by one and making the saveTo the same field as the formula:
In this example, the formula adds one to the Num Purchases field and then saves it back to that field.
Pro Tip #2: Copy Sequences From One Campaign To Another
Don’t forget that you can copy Sequences from one campaign to another.
If you create this as a standalone Sequence in your campaign — meaning the only thing in the Sequence is your Counter HTTP Post Snippet — you can easily copy this as needed to a different campaign.
You can also copy it elsewhere within the same campaign and just change the field names as necessary.
Pro Tip #3: Use Advanced Merge Field Notation
Up until now, it has not been possible to merge information from fields in Opportunities, Tasks, Appointments, Orders and Invoices because for any one contact there could be multiple opportunities, tasks, etc. These have frequently been referred to as “one-too-many” records.
To solve this problem, we created an Advanced Merge Field Notation which allows Pocket Developer Building Blocks to pluck information from a specific field in a specific “one-too-many” record for use as a Building Block Parameter.
For more information on Advanced Merge Field Notation, please see the online documentation at
http://theapiguys.com/blog-post/advanced-merge-field-notation-infusionsoft-documentation/
Pro Tip #4: Chaining Pocket Developer Plug-in
Once you begin using Pocket Developer Building Blocks, you will realize they become even more powerful when chained together.
That is to say, once your first Building Block is completed, the result can be passed to another block and used instead of a Merge Field or constant.
For example, imagine you use Find Opportunity as your first Building Block. Find Opportunity allows you to look for Opportunities by first name, last name, last updated, etc. and returns the ID of the Opportunity.
Pass the result of Find Opportunity (the Opportunity ID) to a second Building Block, called Any Date, Any Format, Anywhere.
Now that you can pass an Opportunity ID to Any Date, you can use it to change the date of any date field within that Opportunity.
Without being able to chain Pocket Developer Building Blocks together, this would be impossible.
How To Chain Pocket Developer Plug-ins
To chain Building Blocks, you will add an optional Key Value Pair.
- The Key is called request and the value is a URL with query strings for a different block
- Example request URL:
http://yourdomain.com/scripts/PocketDeveloper/Blocks/FieldMath/fieldmath.php?formula=a+b&a=Contact._Counter&b={result}&saveTo=Contact._Counter
- In the example URL above, the result of the first Field Math calculation would be passed to Field Math again and used instead of a merge field or constant as the value of the variable b
- When chaining two Pocket Developer Building Blocks together, the saveTo pair is optional for the first block. You may choose to pass the result of the first block to the second block without saving it in an Infusionsoft record
Troubleshooting
- To confirm Field Math is working properly in your application, set up a new campaign in Infusionsoft . Add one Tag Goal with a new tag, such as Run Post. Add one Sequence with an HTTP Post Snippet. Create a simple math function like formula = a+b, a = ~Contact.Username~, b = ~Contact.Password~, ~saveTo~ = Contact.Title (remember no tildes in the saveTo Value field)
- Save and publish the campaign. Set up a test user, like Mickey Mouse. Put 1 in the User Name field, 2 in the Password field. Save and apply the Run Post tag. Wait a minute. When you refresh 3 should be in the Title field if everything is set up properly
- If a result is not being saved to the record in Infusionsoft:
- Field Math requires at least four Key Value Pairs. Make sure you have removed the tildes (~) in the saveTo Value field
- Make sure the HTTP POST Snippet ran by going to the Contact Record and looking under campaigns. This should be about halfway down the page. (You can also see campaigns in Interactive View.) You should see the HTTP Post at the top of Recent Campaign History
- Make sure the URL in the HTTP Post Snippet is pointing to /scripts/PocketDeveloper/Blocks/FieldMath/fieldmath.php on your server
- Make sure there are no spaces in your formula
- If you want the script to combine operations (add, add, add, divide) as is done in finding an average (a + b + c / d = average) try some examples on your calculator before you create the value pairs. The script cannot tell if you have made a mistake in the order of operation or put the wrong field in the Name/Value Pairs
Get More Pocket Developer Plug-ins
The more Pocket Developer Building Blocks you have, the more cool things you can do in Campaign Builder. The following blocks have been released or will be soon.
- Any Date, Any Format, Anywhere – Give the block any date, in any format (e.g. next Monday). It will convert to any valid date/time format and store in a date or date/time field (coming soon)
- Any Text Anywhere – Copy and store text from another field, set a field to a specified text string, or set the value to blank
Automated Stage Moves – Finds Opportunities for a Contact based on criteria you specify and changes the Opportunity Stage (coming soon) - Basic Math – Add, subtract, multiply and divide Infusionsoft field values (coming soon)
- Combine Fields – Combine the value of two fields (concatenate) and store the result (coming soon)
- Counter – Increment or decrement a field by a specified number when run (coming soon)
- Field Math – Do math using up to 52 fields and constants and store the result in a field
- GoToWebinar Integration – Retrieve webinars, register contact, save webinar information in the contact record, and check and tag attendance ld (coming soon)
- Multiple File Uploads – Upload one or more files to the contact’s filebox
- Send A Text (TelAPI) – Send a SMS message using TelAPI (coming soon)
- Send A Text (Twilio) – Send a SMS message using Twilio (coming soon)
- Total Spend – Calculate the total purchases for a contact. You specify whether to pull only paid invoices or all (coming soon)
Don’t see the Building Block you need? Find out how you can sponsor a Building Block for the good of all Infusionites.
Dunne, Foryoo & Phast ImplementationsTM
We also have a number of Dunne, Foryoo & Phast implementations for projects that are just a little too “squishy” for Pocket Developer. Implementations can generally be completed in 24 hours or less. Browse the list for currently available Implementations.
Glossary of Terms
Chaining : Using results of one block in another block. The result of the initial Building Block is passed the a second block by using the Request parameter
contactID: This is the contactID for the contact record where fields will be retrieved (if any) and where the result of the formula evaluation will be stored
Evaluation: The process of running the operations in a formula
Formula: The written description of the variables you want to use and the operations you want done, in the order you want them done. An example formula would be a+b or (a+b)*z
Infusionsoft: A powerful small business automation tool
Key/Value Pair: A parameter name and value passed to the server by a HTTP Post or URL query string
One-To-Many: A relationship between records in a database where one record in one table could relate to more than one records in another table. For example, the relationship between Contacts and Opportunity is one-to-many because a single Contact could have multiple Opportunities
Operations: Add, subtract, multiply, and divide
Order of Operations: Rules used to clarify the order expressions should be evaluated in a mathematical formula
Query String: The part of a URL that contains data to be sent to the location identified in the URL. A post URL contains location information followed by a “?” and what comes after that is the query string
Request: This is the chained Building Block. The merge field {result} can be placed anywhere within the URL to include the result of the first Building Block. This allows you to pass the value to another script/block
saveTo: This is the merge field where the result of the formula will be stored, such as _ArenaHandicap or
_CustomField1. (Optional if using ‘request’)
Variables: Are the names, in the left side of a Key/Value Pair, that refer to the values being added, subtracted, multiplied or divided. In this block, you can have up to 52 variables: a – z and A – Z. For example, in the formula a + b = c, a, b, and c are all variables