• kumar 420
  • NEWBIE
  • 15 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
i Wanna chage this after trigger in before Trigger So we do some help.    
This is my helper class :-HelpClassForSequenceNumberTriggerT:-

public void forUpdateRecordInSequenceField( Contact contactallnewrecord , Contact contactalloldrecord ) {
        Decimal lmt=1;
       accountrecordids.add(contactallnewrecord.accountID);
        List<Contact> contactsameaccountrecord = [Select id,name,Sequence_Number__c from Contact where accountid = :accountrecordids];
        if(contactallnewrecord.Sequence_Number__c > contactalloldrecord.Sequence_Number__c) {
            lmt=contactallnewrecord.Sequence_Number__c - contactalloldrecord.Sequence_Number__c;
        }
        if(contactalloldrecord.Sequence_Number__c > contactallnewrecord.Sequence_Number__c) {
            lmt=contactalloldrecord.Sequence_Number__c - contactallnewrecord.Sequence_Number__c;
        }    
      
        for(Contact singlerecordofcontact : contactsameaccountrecord ) {
            
            if(singlerecordofcontact.Sequence_Number__c > contactalloldrecord.Sequence_Number__c  && singlerecordofcontact.Sequence_Number__c <= contactallnewrecord.Sequence_Number__c && singlerecordofcontact.id != contactallnewrecord.id)  {
                
                for( ;i<=lmt;i++) {
                    singlerecordofcontact.Sequence_Number__c= singlerecordofcontact.Sequence_Number__c-1;
                    System.debug(singlerecordofcontact.Sequence_Number__c);
                    forupdatecontactrecord.add(singlerecordofcontact);
                    break;
                }  
            }
            else if(singlerecordofcontact.Sequence_Number__c < contactalloldrecord.Sequence_Number__c  && singlerecordofcontact.Sequence_Number__c >= contactallnewrecord.Sequence_Number__c && singlerecordofcontact.id != contactallnewrecord.id)  {
                
                for( ;i<=lmt;i++){
                    singlerecordofcontact.Sequence_Number__c= singlerecordofcontact.Sequence_Number__c+1;
                    System.debug(singlerecordofcontact.Sequence_Number__c);
                    forupdatecontactrecord.add(singlerecordofcontact);
                    break;
                    
                }  
            } 
        }
       update forupdatecontactrecord;
    }
   



And This is my after update Trigger:-
if(Trigger.Isupdate)
    {
            for(Contact onenewrecord : Trigger.new )
            {
                for(Contact oneoldrecord : Trigger.old )
                {
                  
                    if(onenewrecord.Sequence_Number__c != oneoldrecord.Sequence_Number__c && onenewrecord.account.id == oneoldrecord.account.id)
                    {
                        obj.forupdateRecordInSequenceField(onenewrecord,oneoldrecord );
                    }
                 break;
  
            }

        }
    } 
 
so give me answer that work on update .  if i update one Sequnce number than only chage two values that mean 
i have sequnce number 1  2   3  4   5    and i will update the 3 hence 5   than   the sequnce is   1   2   5   3  4 only chage that 3  and 5 and not chage another sequnce number
please give me answer
thanks 
hello,
i am new in salesforce so please help
i have two standard object Account(parent) and Contact(child) .so i wanna create a custom field  'sequence number' on Contact .
suppose my Account(parent) Object have 5 Contact(child) the 'sequence number' record is 1,2,3,4,5      Than i will update the 3 'sequence number' in update 5  than  new 'sequence number' is 1,2,5,4,3  
this is done help by 'Apex Trigger'.
help my and example with code  
 
hello,
i have custom field 'sequence number'  on Contact(Child) object .i wanna insert the value in custom field and than i insert the value in next record automatic the next record value is increse from our first record value .
for Example if i have one Account(Parent) Object that Account name is 'HDFC' in the HDFC Account i have 4 Contact(Child) Object in Contact Object i have  'sequence number'  Custom fields in Contact Object.I insert the record in 1 contact 'sequence number'  Custom fields and after than i will insert the record 2 contact 'sequence number'  Custom fields it automaticly increse by one form the 1 contact 'sequence number'  .and then i will insert the 3 contact 'sequence number'  Custom fields it automaticly increse by one form the 2 contact 'sequence number'.and all this sequence for all contact 

i am new in salesforce apex so give me solution with example and some expletion
thank you
....
hello,
i have two standard object Account(parent) and Contact(child) .so i wanna create a custom field  'sequence number' on Contact .
suppose my Account(parent) Object have 5 Contact(child) the 'sequence number' record is 1,2,3,4,5      Than i will delete the One 'sequence number' record 3  so my 4 number come to 3  and 5 number is come to 4.    the new 'sequence number' is 1,2,3,4  
if i will delete any record than the sequence of record number is maintan.
this is done help by 'Apex Trigger'.
help my and example with code  
 
hello,
i am new in salesforce so please help
i have two standard object Account(parent) and Contact(child) .so i wanna create a custom field  'sequence number' on Contact .
suppose my Account(parent) Object have 5 Contact(child) the 'sequence number' record is 1,2,3,4,5      Than i will update the 3 'sequence number' in update 5  than  new 'sequence number' is 1,2,5,4,3  
this is done help by 'Apex Trigger'.
help my and example with code  
 
hello,
i have two standard object Account(parent) and Contact(child) .so i wanna create a custom field  'sequence number' on Contact .
suppose my Account(parent) Object have 5 Contact(child) the 'sequence number' record is 1,2,3,4,5      Than i will delete the One 'sequence number' record 3  so my 4 number come to 3  and 5 number is come to 4.    the new 'sequence number' is 1,2,3,4  
if i will delete any record than the sequence of record number is maintan.
this is done help by 'Apex Trigger'.
help my and example with code