You need to sign in to do that
Don't have an account?

How to write a trigger for copying related list from one master object to another?
Hi ,I have 2 objects "Positions" and "Employment Websites" having many to many relationship between them with "Job Posting" as a junction object.
->I have a case "C1" on "Position"
->Position "P1" is posted to 3 Employement Websites "W1" ,"W2" and "W3"
->My requirement is to show case "C1" on Employement Website "W1" ,"W2" and "W3"
I have written a trigger for the above requirement but i am stuck
Objects :
Position
Employment Websites
Job Posting (Junction object for Position and Employement Websites)
CaseRelatedList( junction object between case and employement websites)
case (look up to Position)
I am trying to copy case related list from Position to Employment Websites .
Trigger :
trigger CloneCaseRelatedList on Case (after insert) {
set<string> posId = new set<string>();
Map<string,Job_Posting__c> posEmpWebsite = new Map<String,Job_Posting__c>();
if(Trigger.isInsert)
{
for(Case c : Trigger.new)
{
posId.add(c.Position__c);
system.debug(posId);
}
}
for(Job_Posting__c j : [Select Position__c ,Employment_Website__c from Job_Posting__c where Position__c in : posId ])
{
posEmpWebsite.put(j.Position__c, j);
system.debug(posEmpWebsite);
}
//I am stuck at this point How I can loop through all employmemt websites that position have
}
1.I have created CaseRelatedList as a junction object for Employement Website and Case
2.Created trigger on case and from there I am getting positions
3.finding employemnt websites related to position through junction object 'Job Posting'
4.Need to loop through result of step 3.
How can I loop through it so that I can insert case and employment website on junction object caseRelatedList.
Thanks in advance!!
->I have a case "C1" on "Position"
->Position "P1" is posted to 3 Employement Websites "W1" ,"W2" and "W3"
->My requirement is to show case "C1" on Employement Website "W1" ,"W2" and "W3"
I have written a trigger for the above requirement but i am stuck
Objects :
Position
Employment Websites
Job Posting (Junction object for Position and Employement Websites)
CaseRelatedList( junction object between case and employement websites)
case (look up to Position)
I am trying to copy case related list from Position to Employment Websites .
Trigger :
trigger CloneCaseRelatedList on Case (after insert) {
set<string> posId = new set<string>();
Map<string,Job_Posting__c> posEmpWebsite = new Map<String,Job_Posting__c>();
if(Trigger.isInsert)
{
for(Case c : Trigger.new)
{
posId.add(c.Position__c);
system.debug(posId);
}
}
for(Job_Posting__c j : [Select Position__c ,Employment_Website__c from Job_Posting__c where Position__c in : posId ])
{
posEmpWebsite.put(j.Position__c, j);
system.debug(posEmpWebsite);
}
//I am stuck at this point How I can loop through all employmemt websites that position have
}
1.I have created CaseRelatedList as a junction object for Employement Website and Case
2.Created trigger on case and from there I am getting positions
3.finding employemnt websites related to position through junction object 'Job Posting'
4.Need to loop through result of step 3.
How can I loop through it so that I can insert case and employment website on junction object caseRelatedList.
Thanks in advance!!
All Answers
Is Case C1 parent for Position or is Position Parent for Case ?
Great!!!
Thanks alot ....That was exactly my requirement .