Hi everyone ,
I have scenario where my data is stored in Map/Dictionary.
Now this has to be stored in record.Each field to be mapped with the respective record field.Considering the volume, Is there a way to use the Field Id to map the value.Example:
a!localvariables(
local!list:{{columnName:"Name",recordFieldId"4567898765"},
local!list:{
{
columnName:"Name",
recordFieldId"4567898765"
},
{columnName:"Desc",recordFieldId"4567856894"},/* Now the data to be mapped */a!foreach(locaL!list,index(record,fv!item.recordFieldId,null))
columnName:"Desc",
recordFieldId"4567856894"
},/* Now the data to be mapped */a!foreach(locaL!list,index(record,fv!item.recordFieldId,null))
)
Discussion posts and replies are publicly visible
No, you cannot use Field IDs to dynamically map data to records.
/* Method 1: Direct casting (recommended for volume) */ cast( recordType!YourRecord, local!mapData ) /* Method 2: Using record constructor */ recordType!YourRecord( recordType!YourRecord.fields.name: local!mapData.name, recordType!YourRecord.fields.desc: local!mapData.desc ) /* For Bulk Operation */ a!forEach( items: local!listOfMaps, expression: cast(recordType!YourRecord, fv!item) )
The Field name in the local and the record are different.I dont want to do it manually since it has large set of fields.
And this local has data of the related records too. So here we cant use direct casting.
Can you provide some example of the data structure you have. If your field id in map is analog to record field's field id then index should work. Yet some more details will be better
Have you considered making a dictionary/map mapping the fieldName to the recordField to store the mappings and then using that for the copy? This would allow you to have recordFields using relationships.
When field names differ between source and record, you must manually map each field using recordType!Record.fields.fieldName: sourceData.differentName.Direct casting only works when field names match exactly. Related records require separate handling after parent records are created.