You need to sign in to do that
Don't have an account?
msimonds
Trigger to delete record from Custom Object : Help Needed
I need some help and I am only asking this because I am new to APEX Triggers:
On the opportunity line item, we have a Picklist. When this picklist value is changed to "Won"
My organization has a process which does the following:
1) On the opportunity line item the value is changed to "Won"
2) A Work flow kicks off that sends an outbound message to our local server
3) This process creates a design win on a custom object called Design_Win__c based off of the opportunity line item that had the value changed. It creates a 1 to 1 relationship with the Opportunity Line Item to Design Win
One process that we allow (currently disabled, but cannot be) is the changing of a part number on that same opportunity line item (this is done by a custom s-control). When the part number is changed, it deletes and creates a new opportunity line item. This assigns a new Id to the line item.
We store the original line item Id on the Design Win that was created, but when the original line item deleted, it breaks the 1 to 1 relationship
What I need to accomplish and need help with, is to write a trigger (if this is possible):
1) when the part is changed, and deletes, on the opportunity line item
2) it would query the design win object using the opp line item Id that we have stored on the Design Win.
3) if there is a record found that matches the query, then delete the record
Can someone please help me here, I have no idea how to write a trigger to do this
Thanks is advance
~Mike
On the opportunity line item, we have a Picklist. When this picklist value is changed to "Won"
My organization has a process which does the following:
1) On the opportunity line item the value is changed to "Won"
2) A Work flow kicks off that sends an outbound message to our local server
3) This process creates a design win on a custom object called Design_Win__c based off of the opportunity line item that had the value changed. It creates a 1 to 1 relationship with the Opportunity Line Item to Design Win
One process that we allow (currently disabled, but cannot be) is the changing of a part number on that same opportunity line item (this is done by a custom s-control). When the part number is changed, it deletes and creates a new opportunity line item. This assigns a new Id to the line item.
We store the original line item Id on the Design Win that was created, but when the original line item deleted, it breaks the 1 to 1 relationship
What I need to accomplish and need help with, is to write a trigger (if this is possible):
1) when the part is changed, and deletes, on the opportunity line item
2) it would query the design win object using the opp line item Id that we have stored on the Design Win.
3) if there is a record found that matches the query, then delete the record
Can someone please help me here, I have no idea how to write a trigger to do this
Thanks is advance
~Mike
~Mike
You should not do SOQL in a loop especially in trigger context as it can have up to 200 records to treat in the same time and the SOQL limit is 100.
You should do that instead :
Best wishes,