Solution: You can create wrapper class and use it in the flow.
Example:
Apex Class: ContactCreation
public without sharing class ContactCreation {
@InvocableMethod(label='create Contact' description='Returns the ContactId')
public static List<String> createContact(List<ContactWrapper> contactWrap) {
contact c = new contact();
c.lastName = contactWrap[0].lastName;
c.FirstName = contactWrap[0].firstName;
c.Email = contactWrap[0].contactEmail;
c.Phone = contactWrap[0].contactPhone;
insert c;
List<String> lstContactId = new List<String>();
lstContactId.add(c.id);
system.debug('lstContactId:'+lstContactId);
return lstContactId;
}
public class ContactWrapper {
@InvocableVariable
public String firstName;
@InvocableVariable
public String lastName;
@InvocableVariable
public String contactEmail;
@InvocableVariable
public String contactPhone;
}
}
create flow: ContactCreation
output: When you run the flow,the contact record gets created successfully.
No comments:
Post a Comment