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

Link Custom object to Opportunity
I am having a custom object which is lookup to opportunity.So i am having CO__c field on Opportunity and Opportunity is related list on Custom object.
So i can link Opportunity to custom object,
I am trying to do this using apex trigger.
Every night custom object records are deleted and recreated,so each time on insert of custom object data,i want to check one particular field and match with opportunity based on that field.
Please help!!
So i can link Opportunity to custom object,
I am trying to do this using apex trigger.
Every night custom object records are deleted and recreated,so each time on insert of custom object data,i want to check one particular field and match with opportunity based on that field.
Please help!!
Can you explain little bit more about your requirement.
Regards,
raja.
I think you need to consider Batch job according to your Requirement.
If you need more help in batch job then explain your requirement in detail.
Actually,i am having a custom object named as 'Project__c' and its is having lookup to Opportunity.So Opportunity is related list on Project__c object and Project__c is a look up field on Opportunity.
Now,Every night we have a job which delets Project records and recreates at 4 AM with one field 'Project Unit'
which will be similar to 'unit number' field on oppportunity.
SO when project record is created,i need to check the project unit field and link opportunity to project record.
EDIT-:I had created a field on project__c which is a lookup to opportunity named as Opportunity__c
Its being updated but value of project__c on opportunity is not being linked becasue of which relatedlist value is not connected.
SO BASICALLY,ITS TO SEARCH AND UPDATE CHILD OBJECT WHEN PARENT OBJECT IS CREATED.(LOOKUP)
sounds simple.but i am missing something.
My code til now
Excuse my typo errors.
Your trigger code is not writed properly and it having big issues like you use index for loop on Opportunity size and code is not bulkified.
And requirement is also not properly defined.
What i understand in your requirement is
1.there is a lookup of opportunity in Project__c.
2.There are Two field one is Project_Unit__c in Project and Unit_Number__c in Opportunity.
3.So When you Create Project there is one filed is visible which is Lookup of Opportunity.
4.When you select Opportunity From lookup and save record Project_Unit__c field is auto populated on detail page of Project which is having the same value as Unit_Number__c.
So if you tell me more about your requirement then i will give you better solution.
Thanks
Hemant
soni.sonihemant.hemant@gmail.com
This is my complete trigger which is working as expected.As you mentioned,its not bulkified could you please mention points what i missed to bulkify this trigger.
Please help me in bulkifying this trigger.