You need to sign in to do that
Don't have an account?
ram_dev
Generate a Case based on Contact field and assigned to user
Hi,
Contacts that have oracleid's sfdc needs to generate case and assigned to perticuler user when contacts are updated.
can anyone help me out from this.
Thanks & Regards
Rama
Hi ram_dev
with out passing any values to new case .
how a case will be created? and you are saying its working fine.
just go with code:-
Trigger updatecontact on Contact(after insert,after update)
{
case[] cases = new case[0];
user u=[select id from user where Name='Hecthick'];
For(Contact con:trigger.new){
If (con.phone != null)//make the condition perfect otherwise it creates multiple cases when ever you edit the contact and save it.
{
Case c = new Case();
c.Subject = 'Remedial Case';
c.Type = 'Remedial Work';
c.Status='Web';
c.ContactId=con.id;
c.origin='Phone';
c.ownerid=u.id;
cases.add(c);
}
}
Insert cases;
}
All Answers
Hi,
i wrote the below trigger but it showss the error like invalid field whoid for sobject case.below is the code; can any one help me from this.
Trigger updatecontact on Contact(after insert,after update)
{
case[] cases = new case[0];
For(Contact con:trigger.new){
If (con.phone != null)
{
cases.add(new case(whoid=con.id));
}
}
Insert cases;
}
Instead of whoid pass Contactid=con.id
Hi anil,
Thankyou. here am update the code which works fine. but i need some more information to assigned case to perticuler user. Any one please helpme out from this problem.
Trigger updatecontact on Contact(after insert,after update)
{
case[] cases = new case[0];
For(Contact con:trigger.new){
If (con.phone != null)
{
cases.add(new case());
}
}
Insert cases;
}
Hi ram_dev
with out passing any values to new case .
how a case will be created? and you are saying its working fine.
just go with code:-
Trigger updatecontact on Contact(after insert,after update)
{
case[] cases = new case[0];
user u=[select id from user where Name='Hecthick'];
For(Contact con:trigger.new){
If (con.phone != null)//make the condition perfect otherwise it creates multiple cases when ever you edit the contact and save it.
{
Case c = new Case();
c.Subject = 'Remedial Case';
c.Type = 'Remedial Work';
c.Status='Web';
c.ContactId=con.id;
c.origin='Phone';
c.ownerid=u.id;
cases.add(c);
}
}
Insert cases;
}
HI anil,
It is working. Thank you for your time. and sorry for the late reply hence was out of offiice these days.
Thankyou
Ram