Files
memory-infrastructure-palace/docs/projects/memorypalace/Apple Notes/ConvertCodesToIds.md

1 line
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
public Map<String, String> convertCodesToIds() { String accountCode = (String)arguments.get('accountCode'); String locationCode = (String)arguments.get('locationCode'); String sessionCode = (String)arguments.get('sessionCode'); String orderCode = (String)arguments.get('orderCode'); Map<String, String> ids = new Map<String, String>(); if (!AvocadoUtils.invalidString(accountCode)) { Account[] acc = [ SELECT Id FROM Account WHERE Code__c = :accountCode ]; if (acc == null || acc.size() == 0) { throw new AvocadoException('Could not find any account from code'); } ids.put('accountId', acc[0].Id); } if (!AvocadoUtils.invalidString(locationCode)) { Location__c[] loc = [ SELECT Id FROM Location__c WHERE Code__c = :locationCode ]; if (loc == null || loc.size() == 0) { throw new AvocadoException('Could not find any location from code'); } ids.put('locationId', loc[0].Id); } if (!AvocadoUtils.invalidString(sessionCode)) { Session__c[] ses = [ SELECT Id FROM Session__c WHERE Code__c = :sessionCode ]; if (ses == null || ses.size() == 0) { throw new AvocadoException('Could not find any session from code'); } ids.put('sessionId', ses[0].Id); } if (!AvocadoUtils.invalidString(locationCode)) { Order[] ord = [ SELECT Id FROM Order WHERE Code__c = :orderCode ]; if (ord == null || ord.size() == 0) { throw new AvocadoException('Could not find any order from code'); } ids.put('orderId', ord[0].Id); } return ids; }