Create/update records if...
📜 This job is an official example from OpenFn.
Metadata​
- Name: Create/update records if...
- Adaptor:
@openfn/language-salesforce
- Adaptor Version:
v2.1.0
- Created date unknown
- Updated date unknown
- Score: 100 (an indicator of how useful this job may be)
Key Functions​
createIf
, dataValue
, field
, fields
, relationship
, upsertIf
Expression​
// Using upsertIf and createIf we can conditionally create or update records if
// some condition in the source data is met.
upsertIf(
// a path which resolves to true/false
dataValue('form.legal.allowedToSync'),
'Patient__c',
'Patient_ID__c',
fields(
field('Name__c', dataValue('form.name')),
field('Patient_ID__c', dataValue('form.identification.govId'))
)
);
createIf(
// or a function which returns true/false
state => state.data.form.completedVisit === 'yes',
'Visit__c',
fields(
field('Date__c', dataValue('form.visit.visit_date')),
field('Type__c', 'checkup'),
relationship(
'Patient__r',
'Patient_ID__c',
dataValue('form.identification.govId')
)
)
);