Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Methode name

Description

Example

on (fieldpath,({ recordId, from, to, record, parent }) )

Listen on changes on a specific field. You can retrieve the record where the change happened as well as the old (from) and the new value (to) and if this is a parent record (package header).

Editing Children Records

updateFieldFromRecord(record, fieldpath, value)

Set a specific value directly in the record object based on the field path. 

Note

If you update a field that is involved in the amount calculation process, the field value can be changed after this operation because amount calculation process has highest priority over custom javascript methods.

Discount limiting example

getFieldFromRecord(record, fieldpath)

Get a specific value from the record object based on the field path.

Editing Children Records

async query({objectName,fields,limit,offset,conditions = [],orderByField,orderByDirection}

Run a SOQL query by parameters to query data from records that are not included in the Campaign Builder.

To prevent security vulnerabilities, the query method is invoked with an object instead of a plain SOQL string.

Querying Accounts

hasChildRecord(record)

Ask if the record has child records as package components. If yes, you can react and perform other actions.

Editing Children Records

getChildRecords(record)

Use this method to iterate through children records of a parent item.

Editing Children Records

onDocumentReady (callback)

Allows to create a function that will be called when every record is loaded in the campaign builder. After that it allows the user to execute code right after all the records are loaded into the Campaign Builder, allowing to modify data, execute queries, copy values, etc.

Editing Values

updateRecords(records)

Allows to apply changes to a list of previously queried Campaign Builder items.

Note

Important: You should always call the method updateRecords when modifying records inside the onDocumentReady method otherwise it will not be reflected on the rendered page.

Editing Values

setFieldError(recordId, fieldpath, message)

Set a custom message for an specific field based on the fieldpath and the recordId.

-

isRelatedField(record, fieldpath)

Return true if the field has isRelated true

-

getRecordsFromRelatedFields(record, fieldpath)

Return all records of a related field inside a children record, if the fields inside are not a related field it will return an empty array

-

getRecordsFromRelatedField(record, fieldpath)

Return all the records of a related field if it’s not a related field it will return an empty array

-

getAllRelatedFieldsFromRecord(record)

Return an array with all the fields that has isRelated true in the record

-

setFieldAsRequired(recordId, field, value)

Will set the indicated field as required or not depending on the value (true or false)

-

setFieldAsReadOnly(recordId, field, value)

Will set the indicated field as read only or not depending on the value (true or false)

-

setFieldAsHidden(recordId, field, value)

Will set the indicated field as hidden or not depending on the value (true or false)

-

...

Making fields available for custom logic

If there are certain fields which you need to reference in your custom logic but don’t want to add them to the shown fields then you can add them to a field in the Item Configuration Settings called “Logic Fields“. The format in which you would use this field is the following:

Code Block
["advendio__billing_category__c"] 

...

Examples

Discount limiting example

...