You need to sign in to do that
Don't have an account?
Travis Lee 6
Invocable Apex Class Struggles
Hey everyone,
I'm trying to create a class that I can invoke with a process but I'm having some trouble. The process exists on the Opportunity and needs to invoke a class that will unsync the current quote. I found a blog post that gave me a headstart on the framework for the class but apparently there's a conflict between future and invocable methods and it definitely must be invocable. I'm not a very experienced developer so any advice would be appreciated! Code below
Travis
I'm trying to create a class that I can invoke with a process but I'm having some trouble. The process exists on the Opportunity and needs to invoke a class that will unsync the current quote. I found a blog post that gave me a headstart on the framework for the class but apparently there's a conflict between future and invocable methods and it definitely must be invocable. I'm not a very experienced developer so any advice would be appreciated! Code below
public class QuoteAutoSyncUtil { @future public static void syncQuote(Map<Id, Id> quoteMap) { Map<Id, Opportunity> oppMap = new Map<Id, Opportunity>(); for(Id currentQuote : quoteMap.keyset()) { Opportunity opp = new Opportunity(); opp.Id = quoteMap.get(currentQuote); opp.SyncedQuoteId = currentQuote; oppMap.put(opp.Id, opp); } update oppMap.values(); } }Thanks!
Travis
Try the code below which works perfectly for me.
Please mark this as best answer if it's resolved.
Best Regards,
Nagendra.P
Yes, the code works perfectly as is, but I need to make it invocable through Process Builder which means I have to add the @Invocable annotation, no? When doing this and attempting to save, I get an error notifying me that future methods cannot also be invocable methods. Also, when attempting to replace future with invocable I get errors that reference the Map on line 4 that I'm not very familiar with. Does that make sense?
Regards,
Travis