Skip to main content
ankushs0002
Known Participant
Apr 16, 2024 9:03 AM UTC
Question

How to store map data into database using record type

I need to input data into the database utilizing the 'write to record data' service. I have mapped out the data and now require storage within the database.

I have converted all data to map now i want to store the same into the database

4 replies

karumurua531442
Participating Frequently
Apr 16, 2024 9:15 AM UTC

hi [mention:22441f4b76d54668b9ec7593ce03ccbd:e9ed411860ed4f2ba0265705b8793d05]  Could you please share your code snippet please

ankushs0002
Known Participant
Apr 16, 2024 9:16 AM UTC

[mention:3510a5189ce1477eaf2e09f5858c87e9:e9ed411860ed4f2ba0265705b8793d05] 

a!localVariables(
local!sheetData: readexcelsheetwithfilter(
excelDocument:192028,
sheetNumber:1,
startRow: 2,
endRow: null(),
startColumn:1,
endColumn: null()
).data,
local!values: a!forEach(
items: local!sheetData,
expression: fv!item
),
cast(
'type!Map?list',
local!values
)
)

Please check it out.

venkatrea696188
Inspiring
Apr 16, 2024 9:18 AM UTC

Do you have respective recordtype?? If yes cast map to Record and use write records

ankushs0002
Known Participant
Apr 16, 2024 9:55 AM UTC
Thank you, everyone! I've finally achieved what I set out to do. Your support means a lot to me. Thanks again!

a!localVariables(
local!sheetData: readExcelSheet(
excelDocument: 192028,
sheetNumber: 0,
startRow: 2,
numberOfColumns: 0
),
local!mapData: cast(typeof(a!map()),local!sheetData),
local!mapDataValues: cast(
typeof({a!map()}),
local!mapData.result
),
a!forEach(
items: local!mapDataValues,
expression: 'recordType!{9c2d97ac-fe71-469b-ad46-b2b43d9e7376}TR Expense'(
'recordType!{9c2d97ac-fe71-469b-ad46-b2b43d9e7376}TR Expense.fields.{21990edd-3e43-4c8e-a725-f51e22f6b9e9}expenseDetails': fv!item.values[1],
'recordType!{9c2d97ac-fe71-469b-ad46-b2b43d9e7376}TR Expense.fields.{db6b765f-187d-43c7-88a7-deaf16361a63}expenseAmount': fv!item.values[2]
)
)
)