List<Account> accountList = [ SELECT Id, Name, AccountNumber FROM Account WHERE Name LIKE 'Test Account - %' AND AccountNumber != NULL LIMIT 5 ]; Map<String, Object> paramMap = new Map<String, Object>{ 'records' => JSON.serialize( accountList ) , 'fieldName' => 'AccountNumber' }; DataWeave.Script dwScript = DataWeave.Script.createScript( 'ListToMap' ); DataWeave.Result result = dwScript.execute( paramMap ); String resultString = result.getValueAsString(); // system.debug( resultString ); Map<String, SObject> objMap = (Map<String, SObject>) JSON.deserialize( resultString, Map<String, SObject>.class ); system.debug( objMap ); system.debug( objMap.get( '1' ) ); system.debug( objMap.get( '101' ) );
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter