I am brand new to Apex, this is my first attempt - I adapted some code from here which is working, but ideally, I'd like to pass the urlencoded variable back to the flow, however, I can't work out how to get it to work. I know I have to change the void out so I can return a value, but changing it throws up more issues. I can see I am passing values from my FlowInputs class into my Invocable Method - do I somehow have to set a variable in that method and then create a list?
public class FormAssemblyEncrypt {
public class FlowInputs {
@InvocableVariable public String urlOppId;
@InvocableVariable public String url;
@InvocableVariable public String key;
@InvocableVariable public String OppId;
}
@InvocableMethod
public static void updateOpp (List<FlowInputs> request) {
String data = request[0].urlOppId.remove('=');
String key = request[0].key;
String url = request[0].url + request[0].urlOppId;
String OppId = request[0].OppId;
Blob mac = Crypto.generateMac('HMacSHA256', Blob.valueOf(data), Blob.valueOf(key));
String sig = EncodingUtil.urlEncode(EncodingUtil.base64Encode(mac), 'UTF-8');
String urlencoded = url + '&signature=' + sig;
outfunds__Funding_Request__c opp = [SELECT Id, FormAssemblyURL__c from outfunds__Funding_Request__c WHERE Id = : OppId];
opp.FormAssemblyURL__c = urlencoded;
database.update(opp);
}
}