You need to sign in to do that
Don't have an account?
Ashok S 7
how to solve the problem
Hi,
When i writing the trigger .In that trigger i write the Map
code
----------------------
trigger contactupdate on Contact (before update,After delete)
{
if(Trigger.isbefore && trigger.isupdate)
{
Map<Id,Account> my = new Map<Id,Account>();
//my = Trigger.newMap;
list<contact>con = new list<contact>();
list<contact> cons = [select id,phone,accountid from contact where accountid in:my.keySet()];
for(contact c:cons)
{
c.phone = my.get(c.accountid).phone;
con.add(c);
}
update con;
}
Map<Id,Account> deleteconn = new Map<Id,Account>();
deleteconn = trigger.oldMap;
if(Trigger.isAfter && Trigger.isdelete)
{
//list<contact>con = new list<contact>();
list<contact> cons = [select id,phone,accountid from contact where accountid in:deleteconn.keySet()];
delete cons;
}
}
when i save the following code it will display the error
Illegal assignment from Map<Id,Contact> to Map<Id,Account>
When i writing the trigger .In that trigger i write the Map
code
----------------------
trigger contactupdate on Contact (before update,After delete)
{
if(Trigger.isbefore && trigger.isupdate)
{
Map<Id,Account> my = new Map<Id,Account>();
//my = Trigger.newMap;
list<contact>con = new list<contact>();
list<contact> cons = [select id,phone,accountid from contact where accountid in:my.keySet()];
for(contact c:cons)
{
c.phone = my.get(c.accountid).phone;
con.add(c);
}
update con;
}
Map<Id,Account> deleteconn = new Map<Id,Account>();
deleteconn = trigger.oldMap;
if(Trigger.isAfter && Trigger.isdelete)
{
//list<contact>con = new list<contact>();
list<contact> cons = [select id,phone,accountid from contact where accountid in:deleteconn.keySet()];
delete cons;
}
}
when i save the following code it will display the error
Illegal assignment from Map<Id,Contact> to Map<Id,Account>
Instead of the following code.
Map<Id,Account> deleteconn = new Map<Id,Account>();
deleteconn = trigger.oldMap;
Map<Id,Contact> deleteconn = new Map<Id,Contact>();
deleteconn = trigger.oldMap;
Thanks & Regards,
N. Vinay Kumar.
All Answers
Instead of the following code.
Map<Id,Account> deleteconn = new Map<Id,Account>();
deleteconn = trigger.oldMap;
Map<Id,Contact> deleteconn = new Map<Id,Contact>();
deleteconn = trigger.oldMap;
Thanks & Regards,
N. Vinay Kumar.
my bad
It's true what chnadra said.
Or if you ca elobarate your requirement, we can help you with exact solution.
Regards,
N. Vinay.