Skip to content

Instantly share code, notes, and snippets.

View alexed1's full-sized avatar

Alex Edelstein alexed1

View GitHub Profile
@alexed1
alexed1 / ApexClassDeployFromApex
Created May 16, 2020 19:16
Deploying ApexClass metadata from Apex
public static MetadataService.DeployOptions getDeployOptions(){
MetadataService.DeployOptions lvDeployOption = new MetadataService.DeployOptions();
lvDeployOption.allowMissingFiles = false;
lvDeployOption.autoUpdatePackage = true;
lvDeployOption.checkOnly = false;
lvDeployOption.ignoreWarnings = true;
lvDeployOption.performRetrieve = false;
lvDeployOption.purgeOnDelete = false;
<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
<decisions>
<processMetadataValues>
<name>index</name>
<value>
<numberValue>0.0</numberValue>
</value>
</processMetadataValues>
<name>myDecision</name>
global with sharing class DeserializeJSONtoSObject {
@InvocableMethod
global static List <Results> parse (List<Requests> requestList) {
System.debug('entering object json parse');
//Wrap the Results object in a List container (an extra step added to allow this interface to also support bulkification)
List<Results> responseWrapper= new List<Results>();
global with sharing class GetLookupCollection {
// convert to a Set of ID's
// setup the query
@InvocableMethod
global static List <Results> get(List<Request> requestList) {
List<Results> responseWrapper = new List<Results>();
import {LightningElement, wire, api, track} from 'lwc';
import {getObjectInfo} from 'lightning/uiObjectInfoApi';
export default class FlowCombobox extends LightningElement {
@api name;
@api label;
@api required = false;
@api flowContextFilterType;
@api valueIsCollection;
@api maxWidth;
public with sharing class SendHTMLEmail {
@invocableMethod(label='Send HTML Email')
public static List<Response> SendEmail(List<Request> requests) {
String HTMLbody = requests[0].HTMLbody;
String plainTextBody = requests[0].plainTextBody;
String subject = requests[0].subject;
String replyEmailAddress = requests[0].replyEmailAddress;
String senderDisplayName = requests[0].senderDisplayName;
public with sharing class GetFirstFromCollection {
@InvocableMethod
public static List <Results> execute (List<Requests> requestList) {
System.debug('entering getFirst');
List<SObject> inputCollection = requestList[0].inputCollection;
Boolean enforceSingle = requestList[0].enforceSingleMember;
//TODO if enforceSingle is set, throw an error if count of input collection is not 1
public with sharing class GenerateCollectionReport {
@InvocableMethod
public static List <Results> generateReport(List<Requests> requestList) {
List<Account> inputCollection = requestList[0].inputCollection;
String shownFields = requestList[0].shownFields;
String reportString = '';
if (inputCollection != null && !inputCollection.isEmpty() && shownFields != null) {
reportString += 'Collection Type: ' + inputCollection[0].getSObjectType().getDescribe().getName() + '\n\n';
List<String> shownFieldsArray = shownFields.replaceAll('[^a-zA-Z0-9\\,]', '').split(',');
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lightningSharingWrapper">
<apiVersion>46.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>SubmitterWrapperLWC</masterLabel>
<description>This is a demo component.</description>
<targets>
<target>lightning__FlowScreen</target>
<target>lightning__RecordPage</target>
global with sharing class GetProducts {
@InvocableMethod
public static List<Results> getProducts(List<Requests> requests)
{
Http http = new Http();
HttpRequest request = new HttpRequest();
String endpoint = requests[0].endpointURL;
System.debug('endpoint is: ' + endpoint);
request.setEndpoint(endpoint);