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

prevent from deleting contact if it has assets
Hi developers,
I was wondering is it possible to prevent from deleting contact record if it has assets related to it? Success community says that trigger is an option. If trigger is the only option, could you help me with that?
Thanks a ton.
I assume the Contact Lookup API name is Contact__c. Try the below code and let me know if it works
Please let me know if it works. Mark it as the best asnwer if it solved your problem.
Thanks,
Jainam Contractor,
Salesforce Consultant,
Varasi LLC
www.varasi.com
All Answers
Understood your roadblock. Can you please check the below code and let me know if it helps.
Please let me know if i was able to remove the roadbloack for you. Please mark it as a solution if it solved the purpose.
Thanks & Regards,
Jainam Contractor,
Salesforce Consultant,
Varasi LLC
www.varasi.com
Hi Jainam,
Sorry for late reply. Thanks a lot for your help, I will try this and will get back to you.
Thanks again, Linas
Dear Jainam,
wow, thanks a ton, works like a charm! Could you help a little bit more, I need the same functionality just if the contact has any Orders, than it cannot be deleted as well. The whole idea is that if the Contact has Orders or/and Assets ir cannot be deleted.
Thank you very much in advance.
Linas
Please check the below code and let me know if it works for you...
Please mark this as the best answer if it solved your purpose.
Cheers...!!!:)
Let me know if you need more assistance.
Thanks & Regards,
Jainam Contractor,
Salesforce Consultant,
Varasi LLC
www.varasi.com
I have made some changes to the code. Can you please try that and let me know if it works.
Please let me know if it works or you need more assistance.
Mark it as the best answer if it solved your purpose.
Thanks,
Jainam Contractor,
Salesforce Consultant,
Varasi LLC
www.varasi.com
What is the field API name that you are using for Contact on the Order Object. I have assumed you might have used some of the Standard Lookup fields. If there is some Custom field for Lookup between Order and Contact then let me know what it is so that i can help.
And it would be possible in both the Scenario whether there is Asset/ Order we can block user from deleting contact.
Please give the API name of the field used for Contact Lookup on Order.
Thanks,
Jainam Contractor
I assume the Contact Lookup API name is Contact__c. Try the below code and let me know if it works
Please let me know if it works. Mark it as the best asnwer if it solved your problem.
Thanks,
Jainam Contractor,
Salesforce Consultant,
Varasi LLC
www.varasi.com
This is absolutelly amazing, works like a charm! Thank you.
As it is first trigger in my life, could you please advise me how to move trigger to production? And how to make code coverage by tests? I know the metadata tools only theoretically.
Thanks so much.
Linas
Can you please close this trail by marking the answer as the solution and start a new trail as the subject of this matter is solved and it should confuse the other community users.
Create a new trail for Deployment and Testing and me or some other community members would help you on the same. This is a developer community best practice.
Please let me know the URL of the new trail and then i can help you on the same.
Thanks,
Jainam Contractor
Yes, sure, thanks a lot Jainam for your help. Can I post link to this thread in the success community, where I have opened same question and people guided me here?
Linas
Also you can create a new thread here as well if that doesn't work out.
BR,
Jainam