You need to sign in to do that
Don't have an account?

covert Map<String,Object> to Map<String,String>
I have a method which creates Map<String,Object> by querying a object. I need to pass this value to a future method which has callout. Since callout method does not accept Sobject type as parameter, i need to convert this Map<String,Object> to Map<String,String>.
Appreciate any insights on this issue
List<SObject> listObjectRecords = database.query('select ' + cusFields + ' from '+ objName + ' WHERE ID = \'' + objId + '\'');
for(SObject sObj : listForMap) {
Map<String,Object> mapObj = (Map<String,Object>)Json.deserializeUntyped(Json.serialize(sObj));
}
Appreciate any insights on this issue
List<SObject> listObjectRecords = database.query('select ' + cusFields + ' from '+ objName + ' WHERE ID = \'' + objId + '\'');
for(SObject sObj : listForMap) {
Map<String,Object> mapObj = (Map<String,Object>)Json.deserializeUntyped(Json.serialize(sObj));
}
What is the key of the map? The record Id? What is the value of the map? a JSON representation of the sobject? Think we need a few more details to help you out. That being said, going off my previous assumptions, here's how you might do it:
List<SObject> listObjectRecords = database.query('select ' + cusFields + ' from '+ objName + ' WHERE ID = \'' + objId + '\'');
for(SObject sObj : listObjectRecords ) {
Map<String,Object> mapObj = (Map<String,Object>)Json.deserializeUntyped(Json.serialize(sObj));
}
listObjectRecords returns me a list which is used to build map<string,object>. Here String is name of the field and Object is value of the field. But i need this as Map<String,String> instead of Map<String,Object>
Regards,
Mahesh