+ Start a Discussion
sushant sussushant sus 

after update trigger

in map ,map<id,list<attachment>> attach=new map<id,list<attachment>>(); i am having id as parent id of attachment as opportunity . opportunity has one field type number count default set as 0
for(id ids: attach.keyset()){
list<attachment> acc= attach.get(ids);
opportunity op= new opportunity(id=ids);
1.system.debug('bbttttttt'+(Integer)acc.size()+'jjjj'+op);
2.op.count__c=op.count__c+(integer)acc.size();
3.system.debug('bbttttttt'+(Integer)acc.size()+'jjjj'+opCount__c);
2 line i am getting null pointer exception
1 line returns me acc size and opportunity id
3 line written me acc.size and null
why this is happening
it use to work when you initalise object as opportunity op= new opportunity(id=ids);
it create instance of that
but now its not working
.................................................

 
Sagar PareekSagar Pareek
at very first line of your code you have nothing in your attach MAP you need to assign something to it.
Sagar PareekSagar Pareek
Means to say you have just intialized the MAP attach but nothing has been put into it.
sushant sussushant sus
i was just explaining you
map has data
i wnt to know the point i mention in bold 1,3 why