function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bingi crm 7bingi crm 7 

I am write a trigger custom obj and opportunity (relationship) .

I am write a trigger custom obj and opportunity (relationship) . 
i create one custom obj(Top_X_Designation__c) in that
1) type(picklist) Contract Flow DownHandoff 
2) Attachment (Check box)
Create one field Handoff Attached with picklist type with values are True, False on Opportunity Object.
Logic :-  If Type (Top X Designation) = "Contract Flow DownHandoff", and "Document Attached" = True then "Handoff Attached" = True, otherwise false.


trigger updaterecord on Top_X_Designation__c (after insert, after update){

  List<ID> OppIds = New List<ID>();

  for(Top_X_Designation__c  o : Trigger.new){
    if(o.Document_Attached__c == True && o.Type__c != 'Contract Flow DownHandoff'){
      OppIds.add(o.Type__c );
    }
  }

  List<Opportunity> oppList = [SELECT id, Handoff_Attached__c,Relationship__c FROM Opportunity WHERE id in :OppIds];
  for(integer i = 0 ; i < oppList.size(); i++){
    oppList[i].Handoff_Attached__c = 'True' ;
  }

  update oppList;
}
Nitin SharmaNitin Sharma
Hi Bingi,

Use
List<Opportunity> oppList = [SELECT id, Handoff_Attached__c,Relationship__c FROM Opportunity WHERE id in :OppIds];
  for(Opportunity opp : oppList){
    opp.Handoff_Attached__c = 'True' ;
  }

  update oppList

 Thanks,
Nitin Sharma
bingi crm 7bingi crm 7
Hi, Nitin Sharma i am modify the code as you said but there not reflect any thing . i want when the child record create automatically parent record will be reflected . But i am not achieve this scenario Thanks & Best Regards, B.Giri Kumar