• transe divain 1
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Parte 1 - Digito Verificador 1 ( aos brasileiros: dá jóinha, please!)
IF( LEN(CPF_ou_CNPJ__c)= 14 , OR(AND(MOD((
( VALUE( MID( CPF_ou_CNPJ__c , 1, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 2, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 3, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 4, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 5, 1 ) ) * 2 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 6, 1 ) ) * 9 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 7, 1 ) ) * 8 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 8, 1 ) ) * 7 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 9, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 10, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 11, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 12, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 13, 1 ) ) * 2 )
), 11
) <= 1
, VALUE( MID( CPF_ou_CNPJ__c , 14, 1 ) ) != 0
)
, AND(MOD((
( VALUE( MID( CPF_ou_CNPJ__c , 1, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 2, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 3, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 4, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 5, 1 ) ) * 2 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 6, 1 ) ) * 9 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 7, 1 ) ) * 8 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 8, 1 ) ) * 7 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 9, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 10, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 11, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 12, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 13, 1 ) ) * 2 ))
, 11 ) > 1
, ( 11 - MOD((
( VALUE( MID( CPF_ou_CNPJ__c , 1, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 2, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 3, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 4, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 5, 1 ) ) * 2 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 6, 1 ) ) * 9 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 7, 1 ) ) * 8 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 8, 1 ) ) * 7 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 9, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 10, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 11, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 12, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 13, 1 ) ) * 2 )
)
, 11
) ) != VALUE( MID( CPF_ou_CNPJ__c , 14, 1 ))
)), false)
Hi,
  I need to autopopulate the number datatype field after the record is deleted.
For example,
I have 5 records and their serial numbers are  1,2,3,4 and 5. If i delete the 3rd record , then the serial number of the 4th record should be automatically populated as 3 and 5th records as 4.
How to achieve this delete operation?

My Trigger Code:

trigger RecordSteps on Record__c(before insert,after delete) 
    {
        List<Record__c> cp = new List<Record__c>(); 
        set<id> id = new set<id>();
        List <AggregateResult> requirements = new List<AggregateResult>();  
       if (Trigger.isBefore && Trigger.isInsert)
       { 
        for(Record__c pt:trigger.new)
        {
         requirements=[select Count(Seq__c) from Record__c];
         if(requirements.size() > 0)
         {
         for(AggregateResult ar:requirements)
         {
         pt.Seq__c = Decimal.ValueOf(String.ValueOf(ar.get('expr0')));
          }
      }
      }
}
      if (Trigger.isAfter&& Trigger.isDelete) 
      {
      for(Record__c pt1:trigger.old)
        {
          }
          }   
     }