• Snigdha Chennupalli
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello everyone,

I have 1 custom object (Dimensions__c) which has a lookup relationship with Account standard object (Dimensions__c is Child).

There is a chechbox on Dimension__c (Repayment_Enabled__c).

Now wehenever i create a dimension this check box is made true automatically.

What my need is that, there should be only one check box true on for a record related to account.
Even though there may be 5 dimension records which are related to 1 account but checkbox should be true for only 1 dimension record. 

I have tried this one, But struck.
As i am new to development Please help me.


trigger paymentcheck on Account (before insert,before update,after insert) {
List<Account> acct = new List<Account>();
    List<Dimensions__c> vwo = new List<Dimensions__c>();   // my custom object
    for(Account a : trigger.new){
       if(Repayment_Enabled__c[0] == 'true'){   // this is the check box field which needs to be true for only one record related account
            Repayment_Enabled__c[1] = false;
        }
            }

}
How to solve this one.
 
  • June 01, 2016
  • Like
  • 0