UrbanPro
true

Learn Salesforce Certification from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Following Custom Objects Are Available In The Organization: Interview Question For Salesforce

Kumar
05/08/2017 0 0

 ChildObject__c

ParentObject__c

Click to see the full question.

Relationship between ChildObject__c and ParentObject__c objects is Lookup relationship.

In case of lookup relationship if we delete the parent object record in child object only the relationship field value will be removed (child records won't be deleted).

But client has a requirement to delete the child object records. How to achieve this?

Write an apex trigger to achieve this functionality.

We should take before delete event. If we take after delete relationship will broke up b/w parent and child object records.

Trigger ParentTrigger on ParentObject__c(before delete) {

   /*

Note:

  • For delete events only trigger.old and triggger.oldMap will be available.

  • trigger.old holds old versions of the records but if we mention that in SOQL query salesforce will automatically convert those records into ids.

   */

   List childLst = [select id, Parent_Object__c from ChildObject__c where Parent_Object__c in: trigger.old];  

   delete childLst;

  }

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Trigger Sceniors - session 5
//Trigger Check Duplicate before insert, before update Set leadid = new Set(); Map<String,Lead> phonemap = new Map<String,Lead>(); Map<String,Lead> emailmap = new Map<String,Lead>();...
S

Salesforce Deployment
A Deployment connection allows customizations to be copied from one organization to another. This list shows the deployment connections allowed from other organizations to this organization, and from this...

Any one can become a Salesforce Admin or Salesforce Developer
There are many opportunities in Salesforce as every organization is moving towards cloud computing nowadays. Salesforce has introduced new features like Salesforce Lightining, Salesforce Wave Analytics,Salesforce...

Trigger Best Practices
Triggers - Best Practices in Salesforce 1. Future methods, SOQL and DML: Avoid writing Future methods, SOQL and DML inside the "For" loop.2. Bulkify the trigger: Start developing the logic...
R

Rajiv Kumar Singh

0 1
0

Salesforce Job based training
Hi All, Who are genuinely searching for a Salesforce job-based training? , That Job-based training will be provided here. 1.We will provide Salesforce Best Realtime Training 2.We will provide...
X

Looking for Salesforce Certification Classes?

The best tutors for Salesforce Certification Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Salesforce Certification with the Best Tutors

The best Tutors for Salesforce Certification Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more