+ Start a Discussion
Code+1Code+1 

Remove last three digits of Record ID

Hello All,

 I am capturing the Record ID in a custom text field using a trigger.
 I would like to remove last three digits from the Record ID captured in the field.

 Please find the trigger below.
 
trigger captureID on Multi__c (before update) {
    for( Multi__c mul : Trigger.new){
        mul.Capture_Record_ID__c = mul.id;
    }
}

For the Record - "a0f9000000AHZCr"
Value captured in mul.Capture_Record_ID__c = "a0f9000000AHZCrAAP"

I need to remove AAP from this field.
Please let me know how i should do.

Thanks !

 
Best Answer chosen by Code+1
viruSviruS
Use Like 
String mulId = mul.id;
mul.Capture_Record_ID__c = mulId.substring(0,mulId.length()-3);

All Answers

viruSviruS
Use Like 
String mulId = mul.id;
mul.Capture_Record_ID__c = mulId.substring(0,mulId.length()-3);
This was selected as the best answer
Code+1Code+1
Hello Buddy,
Thank You... Your code is working fine !!