Snippets Collections
TEXT(MONTH(DATEVALUE({!f_StartDateTimeWithTimeZoneOffset}))) & "/" &
TEXT(DAY(DATEVALUE({!f_StartDateTimeWithTimeZoneOffset}))) & "/" &
TEXT(YEAR(DATEVALUE({!f_StartDateTimeWithTimeZoneOffset}))) & " " &
IF(
    VALUE(MID(TEXT({!f_StartDateTimeWithTimeZoneOffset}), 12, 2)) = 0, 
    "12:" & 
    RIGHT("00" & MID(TEXT({!f_StartDateTimeWithTimeZoneOffset}), 15, 2), 2) & 
    " AM", 
    IF(
        VALUE(MID(TEXT({!f_StartDateTimeWithTimeZoneOffset}), 12, 2)) < 12,
        TEXT(VALUE(MID(TEXT({!f_StartDateTimeWithTimeZoneOffset}), 12, 2))) & ":" & 
        RIGHT("00" & MID(TEXT({!f_StartDateTimeWithTimeZoneOffset}), 15, 2), 2) & 
        " AM",
        IF(
            VALUE(MID(TEXT({!f_StartDateTimeWithTimeZoneOffset}), 12, 2)) = 12,
            "12:" & 
            RIGHT("00" & MID(TEXT({!f_StartDateTimeWithTimeZoneOffset}), 15, 2), 2) & 
            " PM",
            TEXT(VALUE(MID(TEXT({!f_StartDateTimeWithTimeZoneOffset}), 12, 2)) - 12) & ":" & 
            RIGHT("00" & MID(TEXT({!f_StartDateTimeWithTimeZoneOffset}), 15, 2), 2) & 
            " PM"
        )
    )
)
//f_GMTOffset
24 * (DATETIMEVALUE({!$Flow.CurrentDate}) - {!Convert_Today_To_DateTime.datetimeValue})

//Convert_Today_To_DateTime is an UnofficialSF Action - ConvertDateToDatetimeFlowAction

{!dateTimeVariable} + ({!f_GMTOffset}/24)

LEFT($Api.Enterprise_Server_URL_610, FIND( '/services', $Api.Enterprise_Server_URL_610))
public with sharing class DependentPicklistController {

    public static Map<String, DependentPicklistWrapper> getDependentPicklistValuesFiltered(String dependentField, List<String> keys) {
        Map<String, DependentPicklistWrapper> dependentPicklistValues = getDependentPicklistValues(dependentField);

        for (String currentKey : dependentPicklistValues.keySet()) {
            if (!keys.contains(currentKey)) {
                dependentPicklistValues.remove(currentKey);
            }
        }

        return dependentPicklistValues;
    }

    public static Map<String, DependentPicklistWrapper> getDependentPicklistValues(String dependentPickListField) {
        List<String> splitString = dependentPickListField.split('\\.');
        Schema.SobjectField dependentField = Schema.getGlobalDescribe().get(splitString[0]).getDescribe().fields.getMap().get(splitString[1]);
        Map<String, DependentPicklistWrapper> dependentPicklistValues = new Map<String, DependentPicklistWrapper>();
        Schema.DescribeFieldResult dependentFieldResult = dependentField.getDescribe();
        Schema.sObjectField controllerField = dependentFieldResult.getController();

        Schema.DescribeFieldResult controllerFieldResult = controllerField.getDescribe();
        List<Schema.PicklistEntry> controllerValues = (controllerFieldResult.getType() == Schema.DisplayType.Boolean ? null : controllerFieldResult.getPicklistValues());

        String base64map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';

        for (Schema.PicklistEntry entry : dependentFieldResult.getPicklistValues()) {
            if (entry.isActive() && String.isNotEmpty(String.valueOf(((Map<String, Object>) JSON.deserializeUntyped(JSON.serialize(entry))).get('validFor')))) {
                List<String> base64chars = String.valueOf(((Map<String, Object>) JSON.deserializeUntyped(JSON.serialize(entry))).get('validFor')).split('');
                for (Integer i = 0; i < (controllerValues != null ? controllerValues.size() : 2); i++) {
                    Schema.PicklistEntry controllerValue = (Schema.PicklistEntry) (controllerValues == null
                        ? (Object) (i == 1)
                        : (Object) (controllerValues[i].isActive() ? controllerValues[i] : null));

                    Integer bitIndex = i / 6;
                    if (bitIndex > base64chars.size() - 1) {
                        break;
                    }
                    Integer bitShift = 5 - Math.mod(i, 6);
                    if (controllerValue == null || (base64map.indexOf(base64chars[bitIndex]) & (1 << bitShift)) == 0) {
                        continue;
                    }
                    String apiName = controllerValue.getValue();
                    if (!dependentPicklistValues.containsKey(apiName)) {
                        dependentPicklistValues.put(apiName, new DependentPicklistWrapper(new LabelValueWrapper(controllerValue.getLabel(), apiName)));
                    }
                    dependentPicklistValues.get(apiName).addPicklistEntry(new LabelValueWrapper(entry.getLabel(), entry.getValue()));
                }
            }
        }
        return dependentPicklistValues;
    }

    public class LabelValueWrapper {
        @AuraEnabled
        public String label { get; set; }
        @AuraEnabled
        public String value { get; set; }

        public LabelValueWrapper(String label, String value) {
            this.label = label;
            this.value = value;
        }
    }

    public class DependentPicklistWrapper {
        @AuraEnabled
        public List<LabelValueWrapper> dependentPicklist;
        @AuraEnabled
        public LabelValueWrapper entry;

        public DependentPicklistWrapper(LabelValueWrapper entry) {
            this.dependentPicklist = new List<LabelValueWrapper>();
            this.entry = entry;
        }

        public void addPicklistEntry(LabelValueWrapper picklistEntry) {
            this.dependentPicklist.add(picklistEntry);
        }
    }
}
SELECT Id, Name, LastViewedDate, LastRunDate FROM Report WHERE Id = '00O2400000XXXXX' ORDER BY LastViewedDate ASC
1. Create Quick Action to open the Screen Flow on the Parent object (Example - Opportunity)
2. Create List Button on the child object to reference that Quick Action.

Quick Action Developer Name: Add_Products_Related_List

List button syntax:
/lightning/action/quick/SOBJECT.QUICK_ACTION_DEV_NAME?objectApiName&context=RECORD_DETAIL&recordId={!CASESAFEID(OBJECT.Id)}&backgroundContext=%2Flightning%2Fr%2FOpportunity%2F{!CASESAFEID(OBJECT.Id)}%2Fview

Example:

/lightning/action/quick/Opportunity.Add_Products_Related_List?objectApiName&context=RECORD_DETAIL&recordId={!CASESAFEID(Opportunity.Id)}&backgroundContext=%2Flightning%2Fr%2FOpportunity%2F{!CASESAFEID(Opportunity.Id)}%2Fview
IF(
  CONTAINS({!$Flow.FaultMessage}, "REQUIRED_FIELD_MISSING"),
  MID(
    {!$Flow.FaultMessage},
    FIND("REQUIRED_FIELD_MISSING: ", {!$Flow.FaultMessage}) + LEN("REQUIRED_FIELD_MISSING: "),
    FIND(". You can look up ExceptionCode values in the", {!$Flow.FaultMessage}) - FIND("REQUIRED_FIELD_MISSING: ", {!$Flow.FaultMessage}) - LEN("REQUIRED_FIELD_MISSING: ")
  ),
  IF(
    CONTAINS({!$Flow.FaultMessage}, "FIELD_CUSTOM_VALIDATION_EXCEPTION"),
    MID(
      {!$Flow.FaultMessage},
      FIND("FIELD_CUSTOM_VALIDATION_EXCEPTION: ", {!$Flow.FaultMessage}) + LEN("FIELD_CUSTOM_VALIDATION_EXCEPTION: "),
      FIND(". You can look up ExceptionCode values in the", {!$Flow.FaultMessage}) - FIND("FIELD_CUSTOM_VALIDATION_EXCEPTION: ", {!$Flow.FaultMessage}) - LEN("FIELD_CUSTOM_VALIDATION_EXCEPTION: ")
    ),
    IF(
      CONTAINS({!$Flow.FaultMessage}, "_EXCEPTION"),
      MID(
        {!$Flow.FaultMessage},
        FIND("_EXCEPTION: ", {!$Flow.FaultMessage}) + LEN("_EXCEPTION: "),
        FIND(". You can look up ExceptionCode values in the", {!$Flow.FaultMessage}) - FIND("_EXCEPTION: ", {!$Flow.FaultMessage}) - LEN("_EXCEPTION: ")
      ),
      {!$Flow.FaultMessage}
    )
  )
)



/*

For "REQUIRED_FIELD_MISSING" error:

MID({!$Flow.FaultMessage}, FIND('REQUIRED_FIELD_MISSING: ', {!$Flow.FaultMessage}) + LEN('REQUIRED_FIELD_MISSING: '), FIND('. You can look up ExceptionCode values in the', {!$Flow.FaultMessage}) - FIND('REQUIRED_FIELD_MISSING: ', {!$Flow.FaultMessage}) - LEN('REQUIRED_FIELD_MISSING: '))


For "_EXCEPTION" endigns (i.e, "FIELD_CUSTOM_VALIDATION_EXCEPTION"):

MID({!$Flow.FaultMessage}, FIND('_EXCEPTION: ', {!$Flow.FaultMessage}) + LEN('_EXCEPTION: '), FIND('. You can look up ExceptionCode values in the', {!$Flow.FaultMessage}) - FIND('_EXCEPTION: ', {!$Flow.FaultMessage}) - LEN('_EXCEPTION: '))

// Note there are many other exceptions that don't fall into these 2 types. Check the developer guide and make sure the full error is displayed of not found.

// The "SOAP API Developer Guide" is a hyperlink - that's why it's not part of the formula


*/
javascript: (function() {
    window.indexedDB.databases().then(function(dbs) {
        dbs.forEach(db => {
            window.indexedDB.deleteDatabase(db.name);
        });
    }).then(function() {
        location.reload();
    });
})();
{!$CustomMetadata.APINameoftheCMDT__mdt.APINameoftheSpecificCMDT.APINameoftheField}

Example:
{!$CustomMetadata.Generic_Configuration__mdt.Cancelled_Event_Owner.Value__c}
SELECT Id,LogUser.Name, LogLength,Application,Status,DurationMilliseconds,StartTime,RequestIdentifier 
FROM ApexLog 
ORDER BY StartTime DESC
SELECT Id, Name, Owner.Name, OwnerId, CreatedBy.Name 
FROM Report 
USING SCOPE allPrivate 
WHERE Name = 'missing report' and FolderName = 'Private Reports'
SUBSTITUTE({!EmailBody}, "<p>", "<p style='margin-top:0px; margin-bottom:0px;'>")
//Increase the Modal Height

.uiModal flowruntime-flow {
    max-height: 100% !important;
}
 
//Set the Modal Width

.uiModal--medium .modal-container {
    max-width: 400px !important;
}
 

//Hide the Close Button

button.slds-modal__close.closeIcon {
    display: none;
}
 
//Increase the Text Area Fields' Height

textarea {
    min-height: 300px !important;
}
 

//
//Change the Color of Text Area Fields

textarea {
    color: green !important;
    font-weight: 800;
    min-height: 200px !important;
}

//Change the Navigation Bar's Color

.uiModal flowruntime-navigation-bar {
    background-color: lightblue !important;
    border-width: 0 !important;
}

//Add a Background Image

.uiModal flowruntime-flow {
    background-image: url("https://salesforcetime.com/wp-content/uploads/2021/04/sfba3.jpg") !important;
    background-repeat: no-repeat !important;
    background-position: center;
    background-size: cover;
}

.slds-modal__header {
    margin-bottom: 0 !important;
}

//Remove the Borders of the Flow

article.flowRuntimeForFlexipage {
 border: none;
}

//Change the Height of a Data Table

flowruntime-datatable .restrict-scroll {
    max-height: 200px !important;
}
{!$CustomMetadata.APINameoftheCMDT.APINameoftheSpecificCMDT.APINameoftheField}
SELECT Id, ContentDocumentId, LinkedEntityId, ShareType, Visibility 
FROM ContentDocumentLink 
WHERE ContentDocumentId IN (SELECT Id FROM ContentDocument)
SELECT Id,Name,InterviewLabel, InterviewStatus,CreatedDate FROM FlowInterview WHERE InterviewStatus = 'Error'
Sucess Banner:
<div class="slds-box slds-box_small slds-theme_success">
  
Failure Banner:
<div class="slds-box slds-box_small slds-theme_error">

Warning Banner:
<div class="slds-box slds-box_small slds-theme_warning">

Information Banner:
<div class="slds-box slds-box_small slds-theme_shade">

Success Notification 
<div class="slds-scoped-notification slds-theme_success" role="status">

Failure  Notification
<div class="slds-scoped-notification slds-theme_error" role="status">
  
Warning Notification 
<div class="slds-scoped-notification slds-theme_warning" role="status">

SELECT DurableId, FlowDefinitionView.Label, VersionNumber, Status FROM FlowVersionView WHERE FlowDefinitionView.Label LIKE '%PLACE PART OF THE FLOW NAME HERE%' AND Status != 'Active'



/* NOTE: When IMPORTING (Delete Action) - Mark API Type as "Tooling API", limit the batch to 10 and 1 thread (SF Limitation), and change DurableId to ID */
Flow version:
HYPERLINK(LEFT($Api.Enterprise_Server_URL_610, FIND( '/services', $Api.Enterprise_Server_URL_610)) & {!$Record.AccountId}, {!$Record.Account.Name})     
     
Forula version: 
HYPERLINK(LEFT($Api.Enterprise_Server_URL_610, FIND( '/services', $Api.Enterprise_Server_URL_610)) & AccountId, Account.Name)     
global with sharing class BK_FilterCollectionByField {
    global class FilterException extends Exception {}
    @InvocableMethod(label='Filter Collection By Field')
    global static List<Result> filterRecordsByField(List<Request> requests) {
        List<Result> results = new List<Result>();
        for(Request request : requests) {
            // Validate inputs
            if (request.allowEmptyCollection != true && (request.inputRecords == null || request.inputRecords.isEmpty())) {
                throw new FilterException('Input record collection is required but empty.');
            }
            if (request.filterValues == null || request.filterValues.isEmpty()) {
                throw new FilterException('Filter values are required but empty.');
            }
            if (String.isBlank(request.fieldAPIName)) {
                throw new FilterException('Field to filter by is required but empty.');
            }
            List<SObject> filteredRecords = new List<SObject>();
            if (request.allowEmptyCollection == true && (request.inputRecords == null || request.inputRecords.isEmpty())) {
                // Return empty result if allowed
                filteredRecords = new List<SObject>{};
            } else {
                // Prepare the set or list for filter values based on case sensitivity
                Set<String> filterValuesSet = new Set<String>();
                if(request.caseSensitive == true) {
                    filterValuesSet.addAll(request.filterValues);
                } else {
                    for(String value : request.filterValues) {
                        if(value != null) {
                            filterValuesSet.add(value.toLowerCase());
                        }
                    }
                }
                // Filter records
                for(SObject record : request.inputRecords) {
                    Object fieldValueObj = record.get(request.fieldAPIName);
                    if(fieldValueObj != null) {
                        String fieldValue = String.valueOf(fieldValueObj);
                        if(request.caseSensitive == true) {
                            if(filterValuesSet.contains(fieldValue)) {
                                filteredRecords.add(record);
                            }
                        } else {
                            if(filterValuesSet.contains(fieldValue.toLowerCase())) {
                                filteredRecords.add(record);
                            }
                        }
                    }
                }
            }
            Result result = new Result();
            result.filteredRecords = filteredRecords;
            results.add(result);
        }
        return results;
    }
    global class Request {
        @InvocableVariable(label='Input Records' description='Collection of records to filter' required=true)
        global List<SObject> inputRecords;
        @InvocableVariable(label='Filter Values' description='Collection of string values to filter by' required=true)
        global List<String> filterValues;
        @InvocableVariable(label='Field API Name' description='API name of the field to filter by' required=true)
        global String fieldAPIName;
        @InvocableVariable(label='Allow Empty Collection' description='Allow the input record collection to be empty? Default is false')
        global Boolean allowEmptyCollection = false;
        @InvocableVariable(label='Case Sensitive' description='Perform case-sensitive matching? Default is false')
        global Boolean caseSensitive = false;
    }
    global class Result {
        @InvocableVariable(label='Filtered Records' description='Collection of records that match the filter criteria')
        global List<SObject> filteredRecords;
    }
}





Test class:
@isTest
private class BK_FilterCollectionByFieldTest {
    @isTest
    static void testFilterRecordsByField() {
        // Create sample accounts
        Account acc1 = new Account(Name = 'Test Account 1', AccountNumber = '123');
        Account acc2 = new Account(Name = 'Test Account 2', AccountNumber = '456');
        Account acc3 = new Account(Name = 'Test Account 3', AccountNumber = '789');
        insert new List<Account>{acc1, acc2, acc3};
        // Prepare request
        BK_FilterCollectionByField.Request request = new BK_FilterCollectionByField.Request();
        request.inputRecords = new List<SObject>{acc1, acc2, acc3};
        request.filterValues = new List<String>{'123', '789'};
        request.fieldAPIName = 'AccountNumber';
        request.caseSensitive = true;
        // Call the method
        List<BK_FilterCollectionByField.Result> results = BK_FilterCollectionByField.filterRecordsByField(
            new List<BK_FilterCollectionByField.Request>{request}
        );
        // Assert the results
        System.assertEquals(1, results.size(), 'Should return one result object');
        System.assertEquals(2, results[0].filteredRecords.size(), 'Should return two filtered records');
        Set<Id> expectedIds = new Set<Id>{acc1.Id, acc3.Id};
        Set<Id> resultIds = new Set<Id>();
        for(SObject sobj : results[0].filteredRecords) {
            resultIds.add(sobj.Id);
        }
        System.assertEquals(expectedIds, resultIds, 'Filtered records should match expected accounts');
    }
    @isTest
    static void testFilterRecordsByField_CaseInsensitive() {
        // Create sample accounts with varying case in AccountNumber
        Account acc1 = new Account(Name = 'Test Account 1', AccountNumber = 'abc');
        Account acc2 = new Account(Name = 'Test Account 2', AccountNumber = 'DEF');
        Account acc3 = new Account(Name = 'Test Account 3', AccountNumber = 'GHI');
        insert new List<Account>{acc1, acc2, acc3};
        // Prepare request
        BK_FilterCollectionByField.Request request = new BK_FilterCollectionByField.Request();
        request.inputRecords = new List<SObject>{acc1, acc2, acc3};
        request.filterValues = new List<String>{'Abc', 'def'};
        request.fieldAPIName = 'AccountNumber';
        request.caseSensitive = false;
        // Call the method
        List<BK_FilterCollectionByField.Result> results = BK_FilterCollectionByField.filterRecordsByField(
            new List<BK_FilterCollectionByField.Request>{request}
        );
        // Assert the results
        System.assertEquals(1, results.size(), 'Should return one result object');
        System.assertEquals(2, results[0].filteredRecords.size(), 'Should return two filtered records');
        Set<Id> expectedIds = new Set<Id>{acc1.Id, acc2.Id};
        Set<Id> resultIds = new Set<Id>();
        for(SObject sobj : results[0].filteredRecords) {
            resultIds.add(sobj.Id);
        }
        System.assertEquals(expectedIds, resultIds, 'Filtered records should match expected accounts');
    }
    @isTest
    static void testFilterRecordsByField_EmptyCollectionAllowed() {
        // Prepare request with empty inputRecords
        BK_FilterCollectionByField.Request request = new BK_FilterCollectionByField.Request();
        request.inputRecords = new List<SObject>();
        request.filterValues = new List<String>{'123', '789'};
        request.fieldAPIName = 'AccountNumber';
        request.allowEmptyCollection = true;
        // Call the method
        List<BK_FilterCollectionByField.Result> results = BK_FilterCollectionByField.filterRecordsByField(
            new List<BK_FilterCollectionByField.Request>{request}
        );
        // Assert the results
        System.assertEquals(1, results.size(), 'Should return one result object');
        System.assertEquals(0, results[0].filteredRecords.size(), 'Should return zero filtered records');
    }
    @isTest
    static void testFilterRecordsByField_ExceptionOnEmptyCollection() {
        // Prepare request with empty inputRecords
        BK_FilterCollectionByField.Request request = new BK_FilterCollectionByField.Request();
        request.inputRecords = new List<SObject>();
        request.filterValues = new List<String>{'123', '789'};
        request.fieldAPIName = 'AccountNumber';
        request.allowEmptyCollection = false;
        // Call the method and expect exception
        try {
            List<BK_FilterCollectionByField.Result> results = BK_FilterCollectionByField.filterRecordsByField(
                new List<BK_FilterCollectionByField.Request>{request}
            );
            System.assert(false, 'Expected an exception due to empty inputRecords');
        } catch (Exception ex) {
            System.assert(ex instanceof BK_FilterCollectionByField.FilterException, 'Expected a FilterException');
            System.assertEquals('Input record collection is required but empty.', ex.getMessage());
        }
    }
    @isTest
    static void testFilterRecordsByField_ExceptionOnEmptyFilterValues() {
        // Create sample accounts
        Account acc1 = new Account(Name = 'Test Account 1', AccountNumber = '123');
        insert acc1;
        // Prepare request with empty filterValues
        BK_FilterCollectionByField.Request request = new BK_FilterCollectionByField.Request();
        request.inputRecords = new List<SObject>{acc1};
        request.filterValues = new List<String>();
        request.fieldAPIName = 'AccountNumber';
        // Call the method and expect exception
        try {
            List<BK_FilterCollectionByField.Result> results = BK_FilterCollectionByField.filterRecordsByField(
                new List<BK_FilterCollectionByField.Request>{request}
            );
            System.assert(false, 'Expected an exception due to empty filterValues');
        } catch (Exception ex) {
            System.assert(ex instanceof BK_FilterCollectionByField.FilterException, 'Expected a FilterException');
            System.assertEquals('Filter values are required but empty.', ex.getMessage());
        }
    }
    @isTest
    static void testFilterRecordsByField_ExceptionOnEmptyFieldAPIName() {
        // Create sample accounts
        Account acc1 = new Account(Name = 'Test Account 1', AccountNumber = '123');
        insert acc1;
        // Prepare request with empty fieldAPIName
        BK_FilterCollectionByField.Request request = new BK_FilterCollectionByField.Request();
        request.inputRecords = new List<SObject>{acc1};
        request.filterValues = new List<String>{'123'};
        request.fieldAPIName = '';
        // Call the method and expect exception
        try {
            List<BK_FilterCollectionByField.Result> results = BK_FilterCollectionByField.filterRecordsByField(
                new List<BK_FilterCollectionByField.Request>{request}
            );
            System.assert(false, 'Expected an exception due to empty fieldAPIName');
        } catch (Exception ex) {
            System.assert(ex instanceof BK_FilterCollectionByField.FilterException, 'Expected a FilterException');
            System.assertEquals('Field to filter by is required but empty.', ex.getMessage());
        }
    }
}
sfdx auth:logout --orgnametarget my-hub-org
{
    "swagger": "2.0",
    "basePath": "/",
    "info": {
        "version": "1.0",
        "title": "External Service for demo bank",
        "description": "### External Service for demo bank",
        "x-vcap-service-name": "DemoBankRestServices"
    },
    "securityDefinitions": {
        "basicAuth": {
            "type": "basic"
        }
    },
    "security": [{
        "basicAuth": []
    }],
    "tags": [{
        "name": "DemoBankRestServices"
    }],
    "paths": {
        "/accounts/{accountName}": {
            "get": {
                "operationId": "getAccount",
                "summary": "Retrieves an account",
                "description": "Retrieves the account with specific name",
                "consumes": ["text/plain"],
                "produces": ["application/json"],
                "parameters": [{
                    "name": "accountName",
                    "in": "path",
                    "required": true,
                    "type": "string",
                    "description": "Name of the account"
                }],
                "responses": {
                    "200": {
                        "description": "The response when system finds an account with given name",
                        "schema": {
                            "$ref": "#/definitions/accountDetails"
                        }
                    },
                    "400": {
                        "description": "Error response if the account name parameter is less than minimum characters",
                        "schema": {
                            "$ref": "#/definitions/errorModel"
                        }
                    },
                    "404": {
                        "description": "Error response if the account is not supported by service or account is not found",
                        "schema": {
                            "$ref": "#/definitions/errorModel"
                        }
                    }
                }
            },
            "delete": {
                "operationId": "DeleteAccount",
                "summary": "Deletes an account",
                "description": "Deletes the account with specific name",
                "consumes": ["text/plain"],
                "produces": ["application/json"],
                "parameters": [{
                    "name": "accountName",
                    "in": "path",
                    "required": true,
                    "type": "string",
                    "description": "Name of the account"
                }],
                "responses": {
                    "204": {
                        "description": "The response when system finds an account with given name",
                        "schema": {
                            "type": "string"
                        }
                    },
                    "400": {
                        "description": "Error response if the account name parameter is less than minimum characters",
                        "schema": {
                            "$ref": "#/definitions/errorModel"
                        }
                    },
                    "404": {
                        "description": "Error response if the account is not supported by service or account is not found",
                        "schema": {
                            "$ref": "#/definitions/errorModel"
                        }
                    }
                }
            },
            "post": {
                "operationId": "addAccount",
                "summary": "Add an account",
                "description": "Add an account to the database",
                "consumes": ["text/plain"],
                "produces": ["application/json"],
                "parameters": [{
                    "name": "accountName",
                    "in": "path",
                    "required": true,
                    "type": "string",
                    "description": "Name of the account"
                }, {
                    "name": "accountType",
                    "in": "query",
                    "required": true,
                    "type": "string",
                    "description": "The type of account"
                }],
                "responses": {
                    "201": {
                        "description": "The response when the account does not already exist and we can create one",
                        "schema": {
                            "$ref": "#/definitions/accountDetails"
                        }
                    },
                    "409": {
                        "description": "The response when the account already exists and we cannot create one",
                        "schema": {
                            "$ref": "#/definitions/accountDetails"
                        }
                    },
                    "400": {
                        "description": "Error response if the account name parameter is less than minimum characters",
                        "schema": {
                            "$ref": "#/definitions/errorModel"
                        }
                    },
                    "404": {
                        "description": "Error response if the account is not supported by service or account is not found",
                        "schema": {
                            "$ref": "#/definitions/errorModel"
                        }
                    }
                }
            },
            "put": {
                "operationId": "updateAccount",
                "summary": "Updates an account",
                "description": "Updates the account with specified name",
                "consumes": ["text/plain"],
                "produces": ["application/json"],
                "parameters": [{
                    "name": "accountName",
                    "in": "path",
                    "required": true,
                    "type": "string",
                    "description": "Name of the account"
                }, {
                    "name": "accountType",
                    "in": "query",
                    "required": true,
                    "type": "string",
                    "description": "The type of account"
                }],
                "responses": {
                    "200": {
                        "description": "The response when system finds an account with given name",
                        "schema": {
                            "$ref": "#/definitions/accountDetails"
                        }
                    },
                    "400": {
                        "description": "Error response if the account name parameter is less than minimum characters",
                        "schema": {
                            "$ref": "#/definitions/errorModel"
                        }
                    },
                    "404": {
                        "description": "Error response if the account is not supported by service or account is not found",
                        "schema": {
                            "$ref": "#/definitions/errorModel"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "accountDetails": {
            "required": ["id", "name", "type", "availableBal"],
            "properties": {
                "id": {
                    "type": "string",
                    "description": "id"
                },
                "name": {
                    "type": "string",
                    "description": "name"
                },
                "type": {
                    "type": "string",
                    "description": "type"
                },
                "availableBal": {
                    "type": "string",
                    "description": "availableBal"
                }
            }
        },
        "errorModel": {
            "required": ["errorCode", "errorMessage"],
            "properties": {
                "errorCode": {
                    "type": "string",
                    "description": "A service-specific error code."
                },
                "errorMessage": {
                    "type": "string",
                    "description": "A service-specific error code."
                }
            }
        }
    }
}
{
    "messageId": "PfNxko2cChY94KsiU9cvUL",
    "eventId": "client.updated",    
    "eventSchemaVersion": 1.0,
    "eventInstanceOriginationDateTime": "2022-03-07T00:37:23Z",
    "eventData": {
        "siteId": 123,
        "saleId": 96,
        "purchasingClientId": "100001049",
        "payments": [
            {
                "paymentId": 103,
                "paymentMethodId": 14,
                "paymentMethodName": "Cash",
                "paymentAmountPaid": 300,
                "paymentLastFour": null,
                "paymentNotes": null
            }
        ],
        "saleDateTime": "2018-05-03T16:52:23Z",
        "soldById": 10,
        "soldByName": "Jane Doe",
        "locationId": 1,
        "totalAmountPaid": 150,
        "items": [
            {
                "itemId": 78,
                "type": "Service",
                "name": "10 Punch Pass",
                "amountPaid": 150,
                "amountDiscounted": 0,
                "quantity": 1,
                "recipientClientId": "100000009",
                "paymentReferenceId": 44
            },
            {
                "itemId": 79,
                "type": "Service",
                "name": "10 Kick Pass",
                "amountPaid": 150,
                "amountDiscounted": 0,
                "quantity": 1,
                "recipientClientId": "100000009",
                "paymentReferenceId": 44
            }
        ]
    }
}
public class Sale {
public String messageId;
public String eventId;
public Decimal eventSchemaVersion;
public String eventInstanceOriginationDateTime;
public SaleEventData eventData;
}


public class SaleEventData {
public Integer siteId;
public Integer saleId;
public String purchasingClientId;
public List<PaymentDetails> payments;
public String saleDateTime;
public String soldById;
public String soldByName;
public Integer locationId;
public Integer totalAmountPaid;
public List<SaleItemDetails> items;
}

public class PaymentDetails {
public Integer paymentId;
public Integer paymentMethodId;
public String paymentMethodName;
public String paymentAmountPaid;
public Integer paymentLastFour;
public String paymentNotes;
}

public class SaleItemDetails {
public Integer itemId;
public String type;
public String name;
public Integer amountPaid;
public Integer amountDiscounted;
public Integer quantity;
public String recipientClientId;
public Integer paymentReferenceId;
}

Sale mbSale = (Sale)JSON.deserialize(jsonInput, Sale.class);
/* JSON EXAMPLE
{
    "messageId": "PfNxko2cChY94KsiU9cvUL",
    "eventId": "client.updated",    
    "eventSchemaVersion": 1.0,
    "eventInstanceOriginationDateTime": "2022-03-07T00:37:23Z",
    "eventData": {
        "siteId": 123,
        "saleId": 96,
        "purchasingClientId": "100001049",
        "payments": [
            {
                "paymentId": 103,
                "paymentMethodId": 14,
                "paymentMethodName": "Cash",
                "paymentAmountPaid": 300,
                "paymentLastFour": null,
                "paymentNotes": null
            }
        ],
        "saleDateTime": "2018-05-03T16:52:23Z",
        "soldById": 10,
        "soldByName": "Jane Doe",
        "locationId": 1,
        "totalAmountPaid": 150,
        "items": [
            {
                "itemId": 78,
                "type": "Service",
                "name": "10 Punch Pass",
                "amountPaid": 150,
                "amountDiscounted": 0,
                "quantity": 1,
                "recipientClientId": "100000009",
                "paymentReferenceId": 44
            },
            {
                "itemId": 79,
                "type": "Service",
                "name": "10 Kick Pass",
                "amountPaid": 150,
                "amountDiscounted": 0,
                "quantity": 1,
                "recipientClientId": "100000009",
                "paymentReferenceId": 44
            }
        ]
    }
}*/


public class Sale {
public String messageId;
public String eventId;
public Decimal eventSchemaVersion;
public String eventInstanceOriginationDateTime;
public SaleEventData eventData;
}


public class SaleEventData {
public Integer siteId;
public Integer saleId;
public String purchasingClientId;
public List<PaymentDetails> payments;
public String saleDateTime;
public String soldById;
public String soldByName;
public Integer locationId;
public Integer totalAmountPaid;
public List<SaleItemDetails> items;
}

public class PaymentDetails {
public Integer paymentId;
public Integer paymentMethodId;
public String paymentMethodName;
public String paymentAmountPaid;
public Integer paymentLastFour;
public String paymentNotes;
}

public class SaleItemDetails {
public Integer itemId;
public String type;
public String name;
public Integer amountPaid;
public Integer amountDiscounted;
public Integer quantity;
public String recipientClientId;
public Integer paymentReferenceId;
}

Sale mbSale = (Sale)JSON.deserialize(jsonInput, Sale.class);
/* JSON EXAMPLE
{
    "messageId": "PfNxko2cChY94KsiU9cvUL",
    "eventId": "client.updated",    
    "eventSchemaVersion": 1.0,
    "eventInstanceOriginationDateTime": "2022-03-07T00:37:23Z",
    "eventData": {
        "siteId": 123,
        "saleId": 96,
        "purchasingClientId": "100001049",
        "payments": [
            {
                "paymentId": 103,
                "paymentMethodId": 14,
                "paymentMethodName": "Cash",
                "paymentAmountPaid": 300,
                "paymentLastFour": null,
                "paymentNotes": null
            }
        ],
        "saleDateTime": "2018-05-03T16:52:23Z",
        "soldById": 10,
        "soldByName": "Jane Doe",
        "locationId": 1,
        "totalAmountPaid": 150,
        "items": [
            {
                "itemId": 78,
                "type": "Service",
                "name": "10 Punch Pass",
                "amountPaid": 150,
                "amountDiscounted": 0,
                "quantity": 1,
                "recipientClientId": "100000009",
                "paymentReferenceId": 44
            },
            {
                "itemId": 79,
                "type": "Service",
                "name": "10 Kick Pass",
                "amountPaid": 150,
                "amountDiscounted": 0,
                "quantity": 1,
                "recipientClientId": "100000009",
                "paymentReferenceId": 44
            }
        ]
    }
}*/


public class Sale {
public String messageId;
public String eventId;
public Decimal eventSchemaVersion;
public String eventInstanceOriginationDateTime;
public SaleEventData eventData;
}


public class SaleEventData {
public Integer siteId;
public Integer saleId;
public String purchasingClientId;
public List<PaymentDetails> payments;
public String saleDateTime;
public String soldById;
public String soldByName;
public Integer locationId;
public Integer totalAmountPaid;
public List<SaleItemDetails> items;
}

public class PaymentDetails {
public Integer paymentId;
public Integer paymentMethodId;
public String paymentMethodName;
public String paymentAmountPaid;
public Integer paymentLastFour;
public String paymentNotes;
}

public class SaleItemDetails {
public Integer itemId;
public String type;
public String name;
public Integer amountPaid;
public Integer amountDiscounted;
public Integer quantity;
public String recipientClientId;
public Integer paymentReferenceId;
}

Sale mbSale = (Sale)JSON.deserialize(jsonInput, Sale.class);
Select id, name, Parent__r.name, Parent__r.id from Child__c

Select id, name, Parent__r.name,(SELECT id, name, amount__c FROM Children__r) from Parent__c
public Boolean mapContains(Map<id,Object> searchObj, String searchKey, String searchVal){
	for (ID idKey : searchObj.keyset()) {
		System.debug(searchObj.get(idKey).get(searchKey));
		if( searchObj.get(idKey).get(searchKey) == searchVal) {
			System.debug('Match Found'+ searchObj.get(idKey));
			return true;
		}else{
			System.debug('No Match');

		}
	}
	return false;
}
Map<String,String> theOne = new Map<String,String>();
Map<String,String> theTwo = new Map<String,String>();

theOne.put('task', 'Active');
theOne.put('task2', 'Inactive');
theOne.put('task3', 'Inactive');
theOne.put('task4', 'Inactive');

theTwo.put('task', 'Active');
theTwo.put('task2', 'Inactive');
theTwo.put('task3', 'Inactive');
theTwo.put('task4', 'Inactive');

void toggleActive(String taskName, Map<String,String> taskMap){
    taskMap.put(taskName, 'Active'); 
    for(String key : taskMap.keySet()){
        if(key != taskName){
       	 taskMap.put(key, 'Inactive');
        }
    }
}

toggleActive('task3', theTwo);

System.debug(theOne);
System.debug(theTwo);
Human fred = new Human();

fred.setName('Fred');
fred.setAge(18);

fred.Run();
fred.Jump();
fred.Climb();
public class Human {
    public String Name;
    public Integer Age;
    
    public Human(){
      this.Age = 0;
    }
        
    public void setName(String Name){
        this.Name = Name;
    } 
    
    public void setAge(String Name){
        this.Age = Age;
    } 
    
    public void Run(){
        System.debug('Run');
    } 
    
    public void Jump(){
        System.debug('Jump');
    } 
    
    public void Climb(){
        System.debug('Climb');
    } 
}
public class TestClass {
    
    public Static Integer copies = 0;
    
    
    public TestClass(){
        this.add();
    }
    
       
    public void add(){
        copies++;
    } 
    
    public Static void subtract(){
        copies--;
        System.debug(copies);
    } 


}
trigger AccountTrigger on Account (before insert) {

      if(Trigger.isInsert && Trigger.isBefore) {

        
        List<Account> myList = new List<Account>();

        for(Account acct : Trigger.new){
          if(acct.name == 'My Test Account'){
           acct.AnnualRevenue = 0;
           myList.add(acct);
          }
        }

        if(myList.size() >= 0){
          insert myList;
        }
      }   
}
(before insert, after insert,before update, after update, before delete, after delete, after undelete)
trigger ContactTrigger on Contact (before insert) { //Context and Event
   
    if(Trigger.isInsert && Trigger.isBefore) { // Condition
       System.debug(Trigger.new);	// Action
    } 
  
}
public with sharing class ContactTriggerHandler {
    //
    // custom trigger handler setup to handler all triggers received on Contact object
    //
    public Boolean isTriggerExecuted = true;
    private boolean myIsExecuting = false;
    private integer BatchSize = 0;

    public ContactTriggerHandler(boolean isExecuting, integer size) {
        myIsExecuting = isExecuting;
        BatchSize = size;
    }

    //
    // On Before Insert
    //
    public void OnBeforeInsert(List<Contact> contactList){
        List<String> emailList = new  List<String>();
        
        for(Contact contact : contactList){
              emailList.add(contact.email);
        }
        
		List<Contact> newContactList = new List<Contact>();
        List<Lead> leadList = [SELECT id,firstname,lastname, email,LeadSource,phone, MobilePhone,OwnerId,HasOptedOutOfEmail FROM Lead WHERE email IN :emailList];
       
        for(Contact cItem : contactList){
            //Merge
            for(Lead lItem: leadList){
            	cItem.HasOptedOutOfEmail = lItem.HasOptedOutOfEmail;
            	cItem.OwnerId = lItem.OwnerId;
            	cItem.LeadSource = lItem.LeadSource;
            	cItem.MobilePhone = lItem.MobilePhone;
				cItem.phone = lItem.phone;
            	cItem.LeadSource = lItem.LeadSource;
           	 	newContactList.add(cItem);
            }

        }
                

    }

    //
    // On After Insert
    //
    public void OnAfterInsert(List<Contact>  contactList) {
       
        List<String> emailList = new  List<String>(); 
        for(Contact contact : contactList){
              emailList.add(contact.email);
        }
        
        List<Lead> leadList = [SELECT id,firstname,lastname, email,LeadSource,phone, MobilePhone,OwnerId,HasOptedOutOfEmail FROM Lead WHERE email IN :emailList];
        List<Task> taskTransferList = [SELECT Id, Who.Id, Who.Type FROM Task WHERE Who.Type = 'Lead'];
        List<Task> taskUpdate = new List<Task>();
        
        for(Contact cItem : contactList){
            //Move Task to Contact
            for(Lead lItem: leadList){
                if(taskTransferList.size() > 0){
                    for(Task taskItem :taskTransferList){
                        taskItem.whoid = cItem.id;
                        taskUpdate.add(taskItem);
                    }
                }

        
            }
            upsert taskUpdate;
            delete leadList;

        }
  
}
public with sharing class TruncateId {
    public TruncateId() {

    }

    @InvocableMethod(label='Truncate ID' description='Transaction Id on Opportunity Object' category='Opportunity')
    public static void Truncate(List<Opportunity> OppIds){

        ID oppID = OppIds[0].id;

        Opportunity opp = [SELECT id, TranscationId__c, name FROM Opportunity WHERE id = :oppID];

      
        String last6 = opp.TranscationId__c.right(6);
        if(opp.TranscationId__c != null){    
            if(last6 != opp.Name.right(6)){
                opp.name = opp.name + last6;
                update  opp;
            }
        }
      

    }

    public class GetOppId{
        @InvocableVariable(required=true label='Opportunity Id')
        public ID oppID;

    }

}
//Parent to Child
SELECT Name, (SELECT name FROM Sessions__r) FROM Public_Event__c
//Child to Parent
SELECT id, name, Public_Event_Name__r.name, Public_Event_Name__r.id From Sessions__c
public class OutterClass {
    Public String name = 'outterclass';
    
    public void setName(String name){
        this.name = name;
	}
    
    public class InnerClass{
       Public String name = 'innerclass';
    }

}
star

Sun Apr 13 2025 23:00:56 GMT+0000 (Coordinated Universal Time)

#salesforce #screnflow #formula
star

Sun Apr 13 2025 22:59:22 GMT+0000 (Coordinated Universal Time)

#salesforce #screnflow #formula
star

Tue Mar 18 2025 23:56:58 GMT+0000 (Coordinated Universal Time)

#salesforce #screnflow #relatedlist
star

Mon Feb 10 2025 13:05:55 GMT+0000 (Coordinated Universal Time)

#apex #salesforce
star

Sat Feb 01 2025 20:53:34 GMT+0000 (Coordinated Universal Time) https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A8mBfSAJ

#salesforce #screnflow #relatedlist
star

Wed Jan 29 2025 16:27:00 GMT+0000 (Coordinated Universal Time) https://hugolemos.medium.com/launch-flow-modal-from-a-related-list-00aba6590187

#salesforce #screnflow #relatedlist
star

Thu Jan 16 2025 04:06:41 GMT+0000 (Coordinated Universal Time) https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm#

#salesforce #screnflow #formulas
star

Sun Jan 12 2025 01:26:52 GMT+0000 (Coordinated Universal Time) https://github.com/RebbePod/salesforcetools/blob/main/Tools/Bookmarklets/Hard%20Refresh.js

#salesforce #cache
star

Fri Dec 20 2024 00:10:45 GMT+0000 (Coordinated Universal Time) https://salesforcetime.com/2024/04/06/using-custom-metadata-types-in-flow-without-get/

#salesforce #custommetadatatype #flow #cmdt
star

Tue Dec 17 2024 01:42:57 GMT+0000 (Coordinated Universal Time) https://bkonect.atlassian.net/wiki/spaces/BKONECT/pages/557065/Generate+Debug+logs+for+a+System+User

#salesforce #apex #soql
star

Tue Dec 17 2024 00:59:54 GMT+0000 (Coordinated Universal Time)

#salesforce #apex #soql
star

Tue Dec 17 2024 00:58:05 GMT+0000 (Coordinated Universal Time) https://www.linkedin.com/posts/steven-trumble_discovered-a-new-useful-soql-keyword-today-activity-7198366400841678848-AVur/

#flow #salesforce #email
star

Mon Dec 09 2024 22:31:09 GMT+0000 (Coordinated Universal Time) https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007PycvnSAB

#flow #salesforce #email
star

Sat Dec 07 2024 21:20:19 GMT+0000 (Coordinated Universal Time) https://salesforcetime.com/2023/11/15/how-to-control-the-css-of-screen-flows/

#flow #salesforce #ui
star

Thu Nov 21 2024 19:48:17 GMT+0000 (Coordinated Universal Time) https://salesforcetime.com/2024/04/06/using-custom-metadata-types-in-flow-without-get/

#flow #salesforce #cmdt
star

Tue Oct 15 2024 23:18:06 GMT+0000 (Coordinated Universal Time) https://www.linkedin.com/posts/davidmasri_%F0%9D%90%8D%F0%9D%90%9E%F0%9D%90%B0-%F0%9D%90%AC%F0%9D%90%AE%F0%9D%90%A9%F0%9D%90%9E%F0%9D%90%AB-%F0%9D%90%A1%F0%9D%90%9A%F0%9D%90%9C%F0%9D%90%A4-%F0%9D%90%9F%F0%9D%90%A8%F0%9D%90%AE%F0%9D%90%A7%F0%9D%90%9D-ever-activity-7251940478143664129-YeU9?utm_source=share&utm_medium=member_desktop

#flow #salesforce #slds
star

Tue Oct 15 2024 21:23:25 GMT+0000 (Coordinated Universal Time) https://salesforce.stackexchange.com/questions/337563/cant-delete-flow-version-because-its-referenced-by-deleted-flow-interviews

#flow #salesforce #slds
star

Fri Sep 20 2024 21:28:30 GMT+0000 (Coordinated Universal Time) https://unofficialsf.com/build-lightning-styled-screen-flows-that-users-will-love/

#flow #salesforce #slds
star

Thu Sep 19 2024 16:09:18 GMT+0000 (Coordinated Universal Time) https://caleksiev.wixsite.com/olzteam/post/salesforce-hacks-1-mass-delete-salesforce-flow-versions

#salesforce #flows #soql
star

Wed Sep 18 2024 20:48:41 GMT+0000 (Coordinated Universal Time)

#apex #flow #salesforce #formula
star

Wed Sep 18 2024 14:21:44 GMT+0000 (Coordinated Universal Time)

#apex #flow #salesforce
star

Mon Jan 16 2023 12:30:43 GMT+0000 (Coordinated Universal Time)

#salesforce #commandline
star

Tue Jul 05 2022 17:03:53 GMT+0000 (Coordinated Universal Time)

#salesforce #static #keywords #class #apex #json
star

Wed Jun 29 2022 15:22:34 GMT+0000 (Coordinated Universal Time)

#salesforce #static #keywords #class #apex #json
star

Wed Jun 29 2022 00:05:25 GMT+0000 (Coordinated Universal Time)

#salesforce #static #keywords #class #apex #json
star

Wed Jun 29 2022 00:05:22 GMT+0000 (Coordinated Universal Time)

#salesforce #static #keywords #class #apex #json
star

Wed Jun 29 2022 00:05:21 GMT+0000 (Coordinated Universal Time)

#salesforce #static #keywords #class #apex #json
star

Tue Jun 28 2022 04:39:59 GMT+0000 (Coordinated Universal Time)

#salesforce #static #keywords #class #soql
star

Tue Jun 28 2022 04:15:24 GMT+0000 (Coordinated Universal Time)

#apex #salesforce #static #keywords #class
star

Tue Nov 09 2021 23:34:05 GMT+0000 (Coordinated Universal Time)

#apex #salesforce #static #keywords #class
star

Thu Sep 16 2021 17:55:32 GMT+0000 (Coordinated Universal Time)

#apex #salesforce #static #keywords #class
star

Thu Sep 16 2021 17:38:28 GMT+0000 (Coordinated Universal Time) https://www.zenintech.org/blog/creating-your-first-apex-class

#apex #salesforce #static #keywords #class
star

Tue Sep 14 2021 12:51:55 GMT+0000 (Coordinated Universal Time)

#apex #salesforce #trigger #static #keywords
star

Sat Jul 24 2021 16:15:19 GMT+0000 (Coordinated Universal Time)

#apex #salesforce #trigger
star

Sat Jul 24 2021 14:14:46 GMT+0000 (Coordinated Universal Time)

#apex #salesforce #trigger
star

Sat Jul 24 2021 09:42:42 GMT+0000 (Coordinated Universal Time)

#apex #salesforce #trigger
star

Fri Jul 23 2021 00:18:27 GMT+0000 (Coordinated Universal Time)

#apex #salesforce #trigger
star

Sat Jun 05 2021 06:34:17 GMT+0000 (Coordinated Universal Time)

#apex #salesforce
star

Sat Jun 05 2021 01:46:56 GMT+0000 (Coordinated Universal Time)

#apex #salesforce #soql
star

Mon Apr 05 2021 17:47:03 GMT+0000 (Coordinated Universal Time)

#apex #salesforce

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension