You need to sign in to do that
Don't have an account?
Terminusbot
Apex Map: SOQL Query - Data Retrieval at Index
I have created an Apex Map that I populated with a SOQL query. I am on the rerieving end, but getting an error that the index is not valid.
Here is what I am doing:
What am I doing wrong? When I debug the map to the logs here is what is in the Map.
Thanks for any tips and advice!
Here is what I am doing:
Map<ID, SagittaInfo__c> sagLogin = new Map<ID, SagittaInfo__c>([Select Id, Name, Account__c, Username__c, Password__c, Serverpool__c from SagittaInfo__c where Name = 'MAIN']); authHeader.Account = string.ValueOf(saglogin.get('Account__c')); authHeader.Username = string.ValueOf(saglogin.get('Username__c')); authHeader.Password = string.ValueOf(saglogin.get('Password__c')); authHeader.Serverpool = string.ValueOf(saglogin.get('Serverpool__c'));
What am I doing wrong? When I debug the map to the logs here is what is in the Map.
09:16:28:041 USER_DEBUG [2]|DEBUG|Map{a068A000000ZOcDQAW=SagittaInfo__c:{Id=a068A000000ZOcDQAW, Name=MAIN, Account__c=gemdata, Username__c=wksmt, Password__c=adminwk, Serverpool__c=websvc}}
Thanks for any tips and advice!
It should be something like
SagittaInfo__c sObj = sagLogin.get(SFDCID);
if(sObj != null)
{
authHeader.Account = sObj.Account__c;
//remaining statements.
}