Which function do we use to remove a particular field from a record before persisting it?
For example:
recordType!sampleRecord1( id: null, column1: A, column2: B, column3: C, column4: D, column5: E, column6: F, column7: G, column8: H, relationA: recordType!relationA( id: null, column1: A1, column2: B2, column3: C3 )) I want to remove the id field from both sampleRecord1 and relationA before persisting them.
Reason: The downstream database does not handle id: null well, but if the field is missing or field have a value, it works fine.
The output I want to save should be:
recordType!sampleRecord1( column1: A, column2: B, column3: C, column4: D, column5: E, column6: F, column7: G, column8: H, relationA: recordType!relationA( column1: A1, column2: B2, column3: C3 ))
Which function do we use to achieve this? i want to handle it dynamically rather mapping individual fields and then persisting .
Discussion posts and replies are publicly visible
The below code might help you. It gives you the fields which are having only non null values
a!localVariables( local!record: 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details'( 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{190df1d5-68fc-404f-8f5a-a520aa180a6e}id': null, 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{17f5b725-96de-4ba4-850a-a4890c5b0a14}developerDesignation': "Lead", 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{e236bd92-5be6-4638-a80c-2ffeeb87962f}isActive': true() ), reject( fn!isnull, a!foreach( a!keys(local!record), if( a!isNullOrEmpty(local!record[fv!item]), "", fv!item ) ) ) )
That gives the field names / field references, of course, but it doesn't return an instance of the record type with the desired field removed, which was the ask...
Yeah My bad. The below code should solve the issue. i changed the logic to find null values and remove them from the original record.
a!localVariables( local!record: 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details'( 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{190df1d5-68fc-404f-8f5a-a520aa180a6e}id': null, 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{17f5b725-96de-4ba4-850a-a4890c5b0a14}developerDesignation': "Lead", 'recordType!{b1ea8073-bc4b-4054-b4bb-9a8dfc3ce0d5}WTA Developer Details.fields.{e236bd92-5be6-4638-a80c-2ffeeb87962f}isActive': true() ), local!nullfields: reject( fn!isnull, a!forEach( a!keys(local!record), if( a!isNullOrEmpty(local!record[fv!item]), fv!item, "" ) ) ), remove(local!record, local!nullfields) )