• Priti Lokhande
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
hello everyone 
I have create trigger on project object and i want to show project record associated wit h contract if i delete inbetween then count should go with next value not with deleted value.
e. contract number : 00000101
project = p-00000101-1
 p-00000101-2//if deleted then count is be
p-00000101-3 not p-00000101-2

trigger RollupTriggerrContractProjectCount on Project__C (after insert,after delete){     // RollUpApexClass Handlerclass = new RollUpApexClass();    // Handlerclass.rollupCountMethod();     if(Trigger.isAfter && Trigger.isInsert ){​​​​​​​                  Integer count=1;         System.debug('Inside the Trigger');         list<id> contractId =new list<id>();                  for(Project__c p1:Trigger.new )         {​​​​​​​             system.debug('Inside for loop Row 9');             contractId.add(p1.Contract__c);         }​​​​​​​         list<Contract> updatedContract = new list<contract>();         list<Contract>updatedContractAcc = new list<Contract>([select Id,(select Id from Projects__r)from contract]);         for(Contract c1:updatedContractAcc)         {​​​​​​​             system.debug('inside for loop Row 16');             c1.count__c = c1.Projects__r.size();             system.debug('Count of project '+c1.Projects__r.size());             updatedContract.add(c1);                      }​​​​​​​         if(count==1 ){​​​​​​​             try{​​​​​​​                 update updatedContract;                 count++;                 system.debug('Inserted'+updatedContract);             }​​​​​​​catch(Exception e){​​​​​​​                 system.debug('Error'+e);             }​​​​​​​         }​​​​​​​                              }​​​​​​​       if(Trigger.isAfter && Trigger.isDelete ){​​​​​​​
System.debug('Inside the Trigger'); list<id> contractId =new list<id>();
for(Project__c p1:Trigger.old ) {​​​​​​​ system.debug('Inside for loop Row 37 delete operation'); contractId.add(p1.Contract__c); }​​​​​​​ list<Contract> updatedContract = new list<contract>(); list<Contract>updatedContractAcc = new list<Contract>([select Id,(select Id from Projects__r)from contract]); for(Contract c1:updatedContractAcc) {​​​​​​​ system.debug('inside for loop Row 44'); c1.count__c = c1.Projects__r.size(); system.debug('Count of project '+c1.Projects__r.size()); updatedContract.add(c1); }​​​​​​​ try{​​​​​​​ update updatedContract; system.debug('Updated'+updatedContract); }​​​​​​​catch(Exception e){​​​​​​​ system.debug('Error'+e); }​​​​​​​
}​​​​​​​    }​​​​​​​

help for the code 
​​​​​​​Thank you in advance
Problem is when case raise along with attachmnet file is uploded but its fileextension is blank because of this im not able to view the file I try with trigger but shhowing error fileextension field is not writable
hello everyone 
I have create trigger on project object and i want to show project record associated wit h contract if i delete inbetween then count should go with next value not with deleted value.
e. contract number : 00000101
project = p-00000101-1
 p-00000101-2//if deleted then count is be
p-00000101-3 not p-00000101-2

trigger RollupTriggerrContractProjectCount on Project__C (after insert,after delete){     // RollUpApexClass Handlerclass = new RollUpApexClass();    // Handlerclass.rollupCountMethod();     if(Trigger.isAfter && Trigger.isInsert ){​​​​​​​                  Integer count=1;         System.debug('Inside the Trigger');         list<id> contractId =new list<id>();                  for(Project__c p1:Trigger.new )         {​​​​​​​             system.debug('Inside for loop Row 9');             contractId.add(p1.Contract__c);         }​​​​​​​         list<Contract> updatedContract = new list<contract>();         list<Contract>updatedContractAcc = new list<Contract>([select Id,(select Id from Projects__r)from contract]);         for(Contract c1:updatedContractAcc)         {​​​​​​​             system.debug('inside for loop Row 16');             c1.count__c = c1.Projects__r.size();             system.debug('Count of project '+c1.Projects__r.size());             updatedContract.add(c1);                      }​​​​​​​         if(count==1 ){​​​​​​​             try{​​​​​​​                 update updatedContract;                 count++;                 system.debug('Inserted'+updatedContract);             }​​​​​​​catch(Exception e){​​​​​​​                 system.debug('Error'+e);             }​​​​​​​         }​​​​​​​                              }​​​​​​​       if(Trigger.isAfter && Trigger.isDelete ){​​​​​​​
System.debug('Inside the Trigger'); list<id> contractId =new list<id>();
for(Project__c p1:Trigger.old ) {​​​​​​​ system.debug('Inside for loop Row 37 delete operation'); contractId.add(p1.Contract__c); }​​​​​​​ list<Contract> updatedContract = new list<contract>(); list<Contract>updatedContractAcc = new list<Contract>([select Id,(select Id from Projects__r)from contract]); for(Contract c1:updatedContractAcc) {​​​​​​​ system.debug('inside for loop Row 44'); c1.count__c = c1.Projects__r.size(); system.debug('Count of project '+c1.Projects__r.size()); updatedContract.add(c1); }​​​​​​​ try{​​​​​​​ update updatedContract; system.debug('Updated'+updatedContract); }​​​​​​​catch(Exception e){​​​​​​​ system.debug('Error'+e); }​​​​​​​
}​​​​​​​    }​​​​​​​

help for the code 
​​​​​​​Thank you in advance