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
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 !!