Help center / Queries and calculated fields

Queries and data

Queries and calculated fields

Queries decide which Salesforce data goes into your templates. Calculated fields let you add computed values and conditional text.

Create a query

Queries in Arimba use standard SOQL, so if you know Salesforce, you already know the syntax. For SOQL details, see the Salesforce documentation.

  1. Open the Arimba app from the App Launcher.
  2. Go to the Queries tab and click New.
  3. Give the query a name that says which data it returns, for example “AccountDetails”. You use this name in your templates.
  4. Enter your SOQL query in the Statement field and save.
The New Query form with a query name and a SOQL statement
Creating a query in the Arimba app

Data from the current record

End your query with WHERE Id=:recordId. Arimba then returns the data of the record the user is on when they generate the PDF:

SELECT Name, Postcode__c FROM Account WHERE Id=:recordId

If a template always needs the same record, use that record’s Id in the query instead.

Data from related records

With curly brackets {…} you can use a field value of the current record inside a query on another object. That lets you reach data that is several steps away.

Example: you are on an Opportunity. A custom field CaseId__c points to a Case, and that Case points to a second Opportunity. To list the products of that second Opportunity, use:

SELECT Name FROM OpportunityLineItem WHERE OpportunityId IN
(SELECT OpportunityId__c FROM Case WHERE Id = {Opportunity.CaseId__c})

The expression in curly brackets reads CaseId__c from the current Opportunity. The query then finds the related Case and returns the line items of the Opportunity linked to it. [CHECK: the user guide names the Case field both Opportunity__c and OpportunityId__c]

Diagram: from the current Opportunity through a Case to a second Opportunity and its line items
How the query reaches the related records

Create a calculated field

Calculated fields put computed values into your template, for example the discount on an invoice or the number of items in an order. They can also show text depending on a condition.

  1. In the Arimba app, open the Calculated Fields tab and click New.
  2. Enter a name. It must always start with Field., for example Field.Discount. [CHECK: the user guide says a space is needed before and after the field; clarify where]
  3. Enter the calculation under Formula, in JavaScript syntax, and save.

To use a Salesforce value in the formula, you need a query that returns it. Refer to the value like this:

Field.QueryName.OBJECTNAME_FIELDNAME

This example uses the query “CaseTest” and shows a text only if the case has a name:

if (Field.CaseTest.CASE_NAME != "") {"The field contains a value";}
A calculated field record with its name and formula
A calculated field in the Arimba app

To use the calculated field, enter its name, here Field.CaseIfStatement, as the name of a form field in your template. See Templates and field syntax.

Stuck somewhere?

Send us a request with the support form and we’ll find a solution together.