I have a flow that generates an encrypted token for new Campaign Member records. This works perfectly fine for creating one record at a time. When I try to create 188 campaign members I get error An Apex error occurred: System.LimitException: ued:Too many DML statements: 151
. I'm not using any DML statements (to my knowledge: update, insert, create, upsert, delete) in the apex class so I'm not sure why I'm getting this limit exception. I'm putting the records in a collection variable in the flow so if the DML error were to occur it should occur in the update part of the flow, not in the apex class.
Any help is greatly appreciated. I'm currently working to put this into a trigger as I don't think this is possible with flow, although it should be.
Apex Class
//called from Flow
public class encrypt
{
@InvocableMethod
public static List<List<CampaignMember>> CmId(List<CampaignMember> ListCampaignMembers)
{
//String encryptedToken2 = ued.UserCryptoHelper.doEncryptWithUrlEncoding(encryptedToken, 'UTF');
for(CampaignMember cm : ListCampaignMembers)
{
Guest_User_Encryption__c gue = [select Site_Name__c, Guest_User_ID__c from Guest_User_Encryption__c where Site_Name__c =: cm.Site_Name__c];
String encryptedToken = System.EncodingUtil.urlEncode(ued.UserCryptoHelper.doEncrypt(cm.id, gue.Guest_User_ID__c),'UTF-8');
cm.Encrypted_Record_Id__c = encryptedToken;
}
List<List<CampaignMember>> returnList = new List<List<CampaignMember>>();
returnlist.add(listCampaignMembers);
return returnList;
}
}
ued.UserCryptoHelper.doEncrypt
?