public with sharing class TruncateId {
public TruncateId() {
}
@InvocableMethod(label='Truncate ID' description='Transaction Id on Opportunity Object' category='Opportunity')
public static void Truncate(List<Opportunity> OppIds){
ID oppID = OppIds[0].id;
Opportunity opp = [SELECT id, TranscationId__c, name FROM Opportunity WHERE id = :oppID];
String last6 = opp.TranscationId__c.right(6);
if(opp.TranscationId__c != null){
if(last6 != opp.Name.right(6)){
opp.name = opp.name + last6;
update opp;
}
}
}
public class GetOppId{
@InvocableVariable(required=true label='Opportunity Id')
public ID oppID;
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter