npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sf-plugin-formula

v1.1.0

Published

Evaluates a Salesforce formula against one or more records and returns the result for each.

Readme

sf-plugin-formula

NPM Downloads/week License

Evaluates a Salesforce formula against one or more records and returns the result for each - entirely offline, no org connection required.

Built on top of these great open-source projects:

Installation

sf plugins install sf-plugin-formula

Features

  • Multi-record evaluation - evaluate the same formula against multiple records in one run.
  • Flexible input - pass the formula and records as CLI flags, or point to a JSON file containing both.
  • Per-record error reporting - type mismatches, wrong argument counts, and other Formulon errors are reported per record instead of aborting the whole run.
  • Assertion support - add _expected to any record to automatically verify the formula result against an expected value.

Usage

sf formula evaluate --formula 'IF(IsActive__c, Amount__c * 1.1, Amount__c)' --records '[...]'
sf formula evaluate --inputfile ./my-formula.json

Flags

| Flag | Summary | | ------------- | --------------------------------------------------------------------------------------------------------------- | | --formula | Salesforce formula to evaluate. Ignored when --inputfile is provided. | | --records | JSON array of record variable maps. Each element represents one record. Ignored when --inputfile is provided. | | --inputfile | Path to a JSON file containing formula and records. When supplied, --formula and --records are ignored. | | --debug | Enable debug mode for verbose logging. |

Examples

Evaluate a formula with no variables

sf formula evaluate --formula 'IF(TRUE, "Yes", "No")'

Evaluate a formula with variables across multiple records

sf formula evaluate \
  --formula 'Amount__c * 2' \
  --records '[{"Amount__c":{"dataType":"number","value":100,"options":{"length":6,"scale":2}}}]'

Evaluate a formula from a JSON file

sf formula evaluate --inputfile ./my-formula.json

Evaluate a conditional text formula

my-formula.json:

{
  "formula": "IF(IsActive__c, \"Active\", \"Inactive\")",
  "records": [
    { "IsActive__c": { "dataType": "checkbox", "value": true } },
    { "IsActive__c": { "dataType": "checkbox", "value": false } }
  ]
}
sf formula evaluate --inputfile ./my-formula.json

Evaluate a number formula with assertions

Use _expected on any record to assert the result. Records without _expected are still evaluated and their assertion column will just show -.

my-formula.json:

{
  "formula": "Amount__c * 1.1",
  "records": [
    {
      "Amount__c": { "dataType": "number", "value": 100, "options": { "length": 6, "scale": 2 } },
      "_expected": { "dataType": "number", "value": 110 }
    },
    {
      "Amount__c": { "dataType": "number", "value": 200, "options": { "length": 6, "scale": 2 } },
      "_expected": { "dataType": "number", "value": 210 }
    },
    {
      "Amount__c": { "dataType": "number", "value": 500, "options": { "length": 6, "scale": 2 } }
    }
  ]
}
sf formula evaluate --inputfile ./my-formula.json

Input file format

When using --inputfile, the file must be a JSON object with this shape:

{
  "formula": "IF(IsActive__c, Amount__c * 1.1, Amount__c)",
  "records": [
    {
      "IsActive__c": { "dataType": "checkbox", "value": true },
      "Amount__c": { "dataType": "number", "value": 200, "options": { "length": 6, "scale": 2 } }
    },
    {
      "IsActive__c": { "dataType": "checkbox", "value": false },
      "Amount__c": { "dataType": "number", "value": 150, "options": { "length": 6, "scale": 2 } }
    }
  ]
}

Each entry in records is a map of field API name → Formulon variable descriptor:

| Property | Required | Description | | ----------- | -------- | ---------------------------------------------------------------------------------------- | | dataType | Yes | One of: text, number, checkbox, date, time, datetime, geolocation, null. | | value | Yes | The field's value as a native JS type. | | options | No | Additional type options (e.g. length, scale for numbers). Defaults to {}. | | _expected | No | Expected result descriptor. When present, the output shows a PASS/FAIL assertion column. |