You need to sign in to do that
Don't have an account?
Yadu
Need Help in Trigger, Have a Deaaline...
- Update the Sales_Target__c field (Lookup to Sales Target) for Sales Opportunities that match on Officer Code and Close Date/Period Start-End (with Count Against Targets checked)
- SELECT SO.Id, … FROM Sales_Opportunity__c SO,
Sales_Target__c ST
WHERE SO.Count_Against_Targets__c = true
AND SO.Officer_Code__c = ST.Officer_Code__c
AND SO.Close_Date__c <= ST.Target_Period_End__c
AND SO.Close_Date__c >= ST.Target_Period_Start__c
If there are any SalesTarget that match the above criteria i need to update the SalesOppurtunity. sales target field on sales oppurtunity Object. This should handle bulk records
Have a dead line. Please help me.
Thanks
Try...
You may need to do this in a batch process as you could potentially hit script limits depending on how big the sales target list is. I do not see another way to do this unless the sales target is already related to the opportunity. Also, what is there are more than one sales target that meets criteria? What if the sales target is already assigned to another opportunity? some things to think about.
All Answers
Are you doing this on record creation, edit, etc or are you trying to look through all records and update them at specific intervals?
Its on Inserting new records and updating the records. its not on specific intervals.
Hi,
The trigger is After Insert. The logic is whenever a new Sales Oppurtunity record gets created, it should look for the sales Target records for certain critiria, if there exists any sales Target record then update the Sales Oppurtunity record with the matched sales Target ID on the Sales_Target__c field on Sales_Oppurtunity__C Object.
Cirtiria is
Sales Oppurtunity__C.Count_Against_Targets__c = true and
Sales Oppurtunity__C. Officer_code__c = Sales_Target__C. Officer_code__c and
Sales Oppurtunity__C.Close_Date__c <= Sales_Target__C.Target_Period_End__c
AND Sales Oppurtunity__C.Close_Date__c >= Sales_Target__C.Target_Period_Start__c
Thanks!
Try...
You may need to do this in a batch process as you could potentially hit script limits depending on how big the sales target list is. I do not see another way to do this unless the sales target is already related to the opportunity. Also, what is there are more than one sales target that meets criteria? What if the sales target is already assigned to another opportunity? some things to think about.
Thank you so much :)