You need to sign in to do that
Don't have an account?
FabianG
Cross Object Field Update Trigger - Custom to Standard Object
Dear all,
I'm trying to develop an apex trigger that populates a checkbox-field on a standard object if a date-field on a custom object is populated/not empty.
Due to a missing/variable relationship this can't be done using a workflow. Both objects have a unique company-id in common which coult be used to relate them to each other.
I know more or less that I have to build a list in the trigger to retrieve the id's and map them but I can' figure out how to to write a working trigger.
Custom object: SProfile__c
Custom object date-field: ActivationDate__c
Standard object: Lead
Standard object checkbox: Activated__c
Matching ID: CompanyID__c
I hope the information helps. I very much appreciate your help!
Cheers
Fabian
I'm trying to develop an apex trigger that populates a checkbox-field on a standard object if a date-field on a custom object is populated/not empty.
Due to a missing/variable relationship this can't be done using a workflow. Both objects have a unique company-id in common which coult be used to relate them to each other.
I know more or less that I have to build a list in the trigger to retrieve the id's and map them but I can' figure out how to to write a working trigger.
Custom object: SProfile__c
Custom object date-field: ActivationDate__c
Standard object: Lead
Standard object checkbox: Activated__c
Matching ID: CompanyID__c
I hope the information helps. I very much appreciate your help!
Cheers
Fabian
You can of course add/modify the conditions as per your needs!
All Answers
You can of course add/modify the conditions as per your needs!
The code looks like it should do what I want to do.
Unfortunately, the CompanyID Company__c is a string / text-field in our system because we retrieve it from an external system.
Probably for this reason, my testclass gibes me an Error on the ID
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, updateActivatedFieldLead: execution of BeforeInsert
caused by: System.StringException: Invalid id: 1234567
External entry point: []
My Test-Class looks as follows (I had to rename some of the fields relating to our German-speaking system):
Any Ideas what I did wrong?
updateActivatedFieldLead: execution of BeforeUpdate caused by: System.StringException: Invalid id: 62131537: External entry point
So there seems to be any struggle with our internal ID, which derives from an external system and therefore seems to be not accecped by salesforce/trigger. Perhaps I have to try a different ID or mothod to link them up.
We have those searching-profiles attached to a lead in the beginning, both created by an external system. Unfortunately they can't be linked up by a fixed relationship because the searching-profile might furtheron also be attached/related to an account or an opportunity. Just to explain where everything comes from.
I really appreciate your efforts!
Thanks
Fabian