2

When I use sfdx to pull a report, I see custom row formula fields under customDetailFormulas, but when I pull the same report using jsforce, customDetailFormulas are missing and the row summary formulas just don't appear at all.

To reproduce

  1. Create report
  2. Create row formula field
  3. Use jsforce v1.9.3 connection.metadata.readSync to read report

Any suggestions why this might be and how to fix it?

1
6
+50

This is a bug in jsforce. You can work around it by using Analytics API and specifying the latest API version (v52.0 as of this writing):

var jsforce = require("jsforce");
var conn = new jsforce.Connection({
  loginUrl: "https://login.salesforce.com",
  version: "52.0",
});
conn.login("...", "...", function (err, userInfo) {
  if (err) {
    return console.error(err);
  }

  var reportId = "00O...";
  conn.analytics.report(reportId).describe(function (err, meta) {
    if (err) {
      return console.error(err);
    }
    console.log(meta.reportMetadata);
    console.log(meta.reportTypeMetadata);
    console.log(meta.reportExtendedMetadata);
  });
});

Testing this with a report that contains a row-level formula, the response metadata shows the formula:


 customDetailFormula: {
    CDF1: {
      dataType: 'string',
      decimalPlaces: ...,
      description: null,
      formula: '...',
      formulaType: 'text',
      label: '...'
    }
  },

The API version matters. As of this writing jsforce uses v42.0 by default if you don't explicitly specify a version when creating a Connection object. This is too early for Analytics API vis-a-vis customDetailFormula: the latter doesn't show up in the response with v42.

Trying v52.0 with jsforce + Metadata API via metadata.readSync and valid report name, nothing is returned. The same test case works when calling Metadata API directly via SOAP and v52. Thus, this is a jsforce bug.

2
  • This is very close but not quite what I'm looking for as far as I can tell. This is customDetailFormula not customDetailFormulas and is in a different format, eg calculatedFormula instead of formula
    – Kat
    Aug 22 at 14:50
  • It's the same info but presented in a slightly different way. In Metatada API, CustomDetailFormulas is a type and the field is reportCustomDetailFormula (see here). In Analytics API, the field is customDetailFormula, type is Custom Detail Formula. There's a 1:1 correspondence between two representations. If you really wanted to make it look like Metadata API, your custom JS function can grab Analytics response and return an object that looks like Metadata API response.
    – identigral
    Aug 22 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.