You need to sign in to do that
Don't have an account?
Karthik keyan
I have created the trigger where there a update in the master record status field ,resultant update should be in child record.but am getting the error of update the child record.Please see the trigger code and please let me know your suggestion.
I have created the trigger where there a update in the master record status field ,resultant update should be in child record.but am getting the error of update the child record.Please see the trigger code and please let me know your suggestion.
trigger CreateContoofPositionUpdate on Account (after insert,after update){
List<Contact> Cont =new List<Contact>();
Contact con = [select id, Warehouse_14__Rounds__c, Warehouse_14__Status__c,Warehouse_14__Types__c,Warehouse_14__Name__c from Contact limit 1];
for (Account posi: trigger.new)
if(posi.Warehouse_14__Type__c == 'High Level' || posi.Warehouse_14__Functional_Area__c =='Project Management' || posi.Warehouse_14__Functional_Area__c == 'Infrastructure Architect'
|| posi.Warehouse_14__Functional_Area__c == 'Domain Expert'){
con.Warehouse_14__Rounds__c ='Managerial';
con.Warehouse_14__Status__c ='N/A';
con.Warehouse_14__Types__c ='Skype';
con.Warehouse_14__Name__c = posi.id;
}
Cont.add(con);
update Cont;
}
Error Message as :
Error:Apex trigger Warehouse_14.CreateContoofPositionUpdate caused an unexpected exception, contact your administrator: Warehouse_14.CreateContoofPositionUpdate : execution of AfterUpdate caused by: System.QueryException: List has more than 1 row for assignment to SObject:Trigger.Warehouse_14.CreateContoofPositionUpdate : line 6, column 1
Is there further changes needed on the above trigger code.
Regards,
Karthik
trigger CreateContoofPositionUpdate on Account (after insert,after update){
List<Contact> Cont =new List<Contact>();
Contact con = [select id, Warehouse_14__Rounds__c, Warehouse_14__Status__c,Warehouse_14__Types__c,Warehouse_14__Name__c from Contact limit 1];
for (Account posi: trigger.new)
if(posi.Warehouse_14__Type__c == 'High Level' || posi.Warehouse_14__Functional_Area__c =='Project Management' || posi.Warehouse_14__Functional_Area__c == 'Infrastructure Architect'
|| posi.Warehouse_14__Functional_Area__c == 'Domain Expert'){
con.Warehouse_14__Rounds__c ='Managerial';
con.Warehouse_14__Status__c ='N/A';
con.Warehouse_14__Types__c ='Skype';
con.Warehouse_14__Name__c = posi.id;
}
Cont.add(con);
update Cont;
}
Error Message as :
Error:Apex trigger Warehouse_14.CreateContoofPositionUpdate caused an unexpected exception, contact your administrator: Warehouse_14.CreateContoofPositionUpdate : execution of AfterUpdate caused by: System.QueryException: List has more than 1 row for assignment to SObject:Trigger.Warehouse_14.CreateContoofPositionUpdate : line 6, column 1
Is there further changes needed on the above trigger code.
Regards,
Karthik
Can you try the below code.
Mark this as best answer if this resolves your issue.
Feel free to reach out if you are still facing the issue.
Regards,
Sanpreet
All Answers
Can you try the below code.
Mark this as best answer if this resolves your issue.
Feel free to reach out if you are still facing the issue.
Regards,
Sanpreet
I have created another trigger on the same kind of coding on others 2 objects,the trigger coding seems to fine but seems not creating child records when insert or update event changes on parent record.Why manipulation was not happening i dont know .Please send your suggestion on this trigger too.
trigger CreateInterviewoofPositionUpdate on Warehouse_14__Position__c (after insert,after update){
List<Warehouse_14__Interviews__c> interview =new List<Warehouse_14__Interviews__c>();
//Warehouse_14__Interviews__c inte = new Warehouse_14__Interviews__c();
if(Trigger.isInsert)
{
for(Warehouse_14__Position__c posi:[ select id,Name,Warehouse_14__Type__c ,Warehouse_14__Functional_Area__c, (select id, Warehouse_14__Rounds__c,Warehouse_14__Status__c,Warehouse_14__Types__c,Warehouse_14__Name__c
from Warehouse_14__Interviews__r ) from Warehouse_14__Position__c where id IN : trigger.new]){
for(Warehouse_14__Interviews__c inte:posi.Warehouse_14__Interviews__r) {
if(posi.Warehouse_14__Type__c == 'High Level' || posi.Warehouse_14__Functional_Area__c =='Project Management' || posi.Warehouse_14__Functional_Area__c == 'Infrastructure Architect'
|| posi.Warehouse_14__Functional_Area__c == 'Domain Expert'){
inte.Warehouse_14__Rounds__c ='Managerial';
inte.Warehouse_14__Status__c ='N/A';
inte.Warehouse_14__Types__c ='Telephonic';
inte.Warehouse_14__Name__c = posi.Id;
} else if(posi.Warehouse_14__Type__c == 'Low Level' || posi.Warehouse_14__Functional_Area__c =='Developer' || posi.Warehouse_14__Functional_Area__c == 'DB Admin'
|| posi.Warehouse_14__Functional_Area__c == 'Telecom Division'){
inte.Warehouse_14__Rounds__c ='Technical';
inte.Warehouse_14__Status__c ='N/A';
inte.Warehouse_14__Types__c ='Skype';
inte.Warehouse_14__Name__c = posi.Id;
} else if(posi.Warehouse_14__Type__c == 'Middle Level' || posi.Warehouse_14__Functional_Area__c =='Banking' || posi.Warehouse_14__Functional_Area__c == 'Insurance'
|| posi.Warehouse_14__Functional_Area__c == 'Product Inside Sales'){
inte.Warehouse_14__Rounds__c ='Human Resources';
inte.Warehouse_14__Status__c ='N/A';
inte.Warehouse_14__Types__c ='Face To Face';
inte.Warehouse_14__Name__c = posi.Id;
}
interview.add(inte);
}
}
insert interview;
} else {
for(Warehouse_14__Position__c posi:[ select id,Name,Warehouse_14__Type__c ,Warehouse_14__Functional_Area__c, (select id, Warehouse_14__Rounds__c,Warehouse_14__Status__c,Warehouse_14__Types__c,Warehouse_14__Name__c
from Warehouse_14__Interviews__r ) from Warehouse_14__Position__c where id IN : trigger.new]){
for(Warehouse_14__Interviews__c inte:posi.Warehouse_14__Interviews__r) {
if(posi.Warehouse_14__Type__c == 'High Level' || posi.Warehouse_14__Functional_Area__c =='Project Management' || posi.Warehouse_14__Functional_Area__c == 'Infrastructure Architect'
|| posi.Warehouse_14__Functional_Area__c == 'Domain Expert'){
inte.Warehouse_14__Rounds__c ='Managerial';
inte.Warehouse_14__Status__c ='N/A';
inte.Warehouse_14__Types__c ='Telephonic';
inte.Warehouse_14__Name__c = posi.Id;
}
else if(posi.Warehouse_14__Type__c == 'Low Level' || posi.Warehouse_14__Functional_Area__c =='Developer' || posi.Warehouse_14__Functional_Area__c == 'DB Admin'
|| posi.Warehouse_14__Functional_Area__c == 'Telecom Division'){
inte.Warehouse_14__Rounds__c ='Technical';
inte.Warehouse_14__Status__c ='N/A';
inte.Warehouse_14__Types__c ='Skype';
inte.Warehouse_14__Name__c = posi.Id;
}
else if(posi.Warehouse_14__Type__c == 'Middle Level' || posi.Warehouse_14__Functional_Area__c =='Banking' || posi.Warehouse_14__Functional_Area__c == 'Insurance'
|| posi.Warehouse_14__Functional_Area__c == 'Product Inside Sales'){
inte.Warehouse_14__Rounds__c ='Human Resources';
inte.Warehouse_14__Status__c ='N/A';
inte.Warehouse_14__Types__c ='Face To Face';
inte.Warehouse_14__Name__c = posi.Id;
}
interview.add(inte);
}
}
update interview;
}
}
Thanks and Regards,
Karthikeyan