upsert(
'Patient__c',
'Patient_ID__c',
fields(
field('Name__c', dataValue('name')),
field('b', 2),
// Omit field if test fails
state.data.testValue > 1 && field('c', dataValue('something')),
// Omit field with ternary if test fails
state.data.anotherTest ? field('d', 13) : '',
// Ternary to change field
state.data.finalTest ? field('e', 16) : '',
// Ternary to change value
field('f', state => {
console.log('this is common place to calculate a value');
const something = state.data.thatOne;
const somethingElse = 4 * 2.42 + state.data.testValue;
if (state.data.test === 'foo') {
return something;
}
return somethingElse;
})
)
);