Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- Possible bug with Maps
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Possible bug with Maps
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-28-2013 04:31 PM
Hi All,
Possible bug with Apex Maps. Am seeing very strange and prohibitive behaviour - any comments welcome.
Code is as follows - idea is to take some map values to a list, then update them.
In this example there is one record in the map - lets try to put it in a list then update it.
// update positions
if(!posMap.isEmpty()){
List<Position__c> posUpdates = new List<Position__c>();
posUpdates = posMap.Values();
system.debug('posUpdate record -->'+posUpdates[0]);
system.debug('id ->'+posUpdates[0].id);
system.debug('Affiliation_Final__c >'+posUpdates[0].Affiliation_Final__c);
update posUpdates;
}K - now what does the debug log show?
USER_DEBUG|[403]|DEBUG|posUpdate record -->Position__c:{Affiliation_Final__c=a03N0000000mQ EKIA2 RecordTypeId=01290000000f9xxAAA, Position_Type__c=Junior Warden, Date_of_Installation__c=2013-03-12 00:00:00, Id=a07N0000000iA6lIAE }
11:21:17.825 (825418000)|USER_DEBUG|[404]|DEBUG|id ->null
11:21:17.825 (825468000)|USER_DEBUG|[405]|DEBUG|Affiliation_Fin al__c ->null
11:21:17.825 (825516000)|DML_BEGIN|[406]|Op:Update|Type:Positio n__c|Rows:1
11:21:17.826 (826821000)|DML_END|[406]
11:21:17.826 (826971000)|EXCEPTION_THROWN|[406]|System.DmlExcep tion: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specifiedFor some reason the value in the map doesnt make it to the list, and we then get obvious error ....
Any ideas anyone?
Re: Possible bug with Maps
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-29-2013 02:13 AM
Hi,
Can you post how you have declared posMap,I want to see the key and value for that.
If this answers your query,please mark this as solution so that it would be useful for others.
Re: Possible bug with Maps
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-29-2013 03:10 AM
Hiya Vinit.
Thanks for having a think about this one!
Map<id,Position__c> posMap = new Map<id,Position__c>(); // map of complete list of positions to process on approved lm record
Then -
in a loop I populate
posMap.put(pos.id, pos);
Per the debug, there is definitely values in the value - but once I extract the value it is stripped of its attributes.
Re: Possible bug with Maps
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-29-2013 03:40 AM
Hi,
Can you also post the SOQL query that you use for querying the position object ( which you use in the for loop to get the id and postion object to be put in the Map)?
Thanks
Re: Possible bug with Maps
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-29-2013 03:48 AM
Absolutely - see the following
for(Position__c pos : [Select p.id,
p.Affiliation_Final__c,
p.RecordTypeId,
p.Position_Type__c,
p.Date_of_Installation__c
From Position__c p ]){
posMap.put(pos.id,pos);
}
Re: Possible bug with Maps
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-29-2013 09:10 AM
Hi,
This looks weird to me as well.I would suggest to make the debug log level to finest and then check the logs again to see somthing happened in betwen or not or if you have done enough debugging,I would suggest to contact salesforce support for this.
If this answers your query,please mark this as solution so that it would be useful for others.
Re: Possible bug with Maps
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-29-2013 02:17 PM
Thanks guys for your efforts to help me out here.
The problem remains unsolved, and looking into finest debug log I can get it is clear that there is some sort of corruption from map to list that means no params are accessible.
I'll take up with Salesforce support... totally weird!

