Skip to content

Instantly share code, notes, and snippets.

View msrivastav13's full-sized avatar
🎯
Focusing

Mohith Shrivastava msrivastav13

🎯
Focusing
View GitHub Profile
@msrivastav13
msrivastav13 / CI.yml
Last active October 12, 2021 09:04
Simple github action YML to deploy experience cloud site to salesforce orgs
# Unique name for this workflow
name: Salesforce CI
# Definition when the workflow should run
on:
push:
branches:
- '*'
# Jobs to be executed
jobs:
@msrivastav13
msrivastav13 / slack_salesforce_oauth
Last active July 15, 2021 15:20
Slack Salesforce OAuth
const { App, LogLevel, ExpressReceiver } = require('@slack/bolt');
const jsforce = require('jsforce'); //jsforce open source library to connect to Salesforce
// Create Salesforce Connection
const oauth2 = new jsforce.OAuth2({
// you can change loginUrl to connect to sandbox or prerelease env.
// loginUrl : 'https://test.salesforce.com',
clientId: process.env.SALESFORCE_CLIENT_ID,
clientSecret: process.env.SALESFORCE_CLIENT_SECRET,
redirectUri: 'https://94d7e0bbbc0e.ngrok.io/salesforce/oauth_redirect'
@msrivastav13
msrivastav13 / tasks.json
Created October 24, 2020 00:23
This is task.json for tailing logs
{
"version": "2.0.0",
"tasks": [
{
"label": "SFDX: Tail Logs",
"type": "shell",
"command": "sfdx",
"args": [
"force:apex:log:tail",
"-c",
@msrivastav13
msrivastav13 / tasks.json
Created October 12, 2020 21:02
This one is for Retrieving org metadata using packages
{
"version": "2.0.0",
"tasks": [
{
"label": "SFDX: Retrieve Metadata From Package",
"type": "shell",
"command": "sfdx",
"args": [
"force:source:retrieve",
"-n",
@msrivastav13
msrivastav13 / tasks.json
Last active October 30, 2020 20:00
Run Salesforce CLI scanner on current file
{
"version": "2.0.0",
"tasks": [
{
"label": "SFDX: Run Security Scan on Current File",
"type": "shell",
"command": "sfdx",
"args": [
"scanner:run",
"-t",
@msrivastav13
msrivastav13 / functions cheat sheet
Last active July 1, 2021 10:22
salesforce functions cheatsheet
//Create a salesforce functions
$ sfdx evergreen:function:init <MyFunction> -l typescript -m force-app/main/default
// Start a function
$ cd functions/MyFunction
$ sfdx evergreen:function:start --verbose
// $ sfdx evergreen:function:invoke \
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ActionLinkGroupTemplate</name>
</types>
<types>
<members>*</members>
<name>ApexClass</name>
</types>
{
"Metadata": {
"actionCalls": [{
"actionName": "emailSimple",
"actionType": "emailSimple",
"connector": null,
"dataTypeMappings": [],
"description": null,
"faultConnector": null,
"inputParameters": [{
@msrivastav13
msrivastav13 / Questionnaireflow.json
Created June 15, 2020 01:13
Questionnaireflow.json
{
"size" : 1,
"totalSize" : 1,
"done" : true,
"queryLocator" : null,
"entityTypeName" : "Flow",
"records" : [ {
"attributes" : {
"type" : "Flow",
"url" : "/services/data/v49.0/tooling/sobjects/Flow/301B00000006sh9IAA"
@msrivastav13
msrivastav13 / Rollback_platform_event
Created April 27, 2020 13:41
Rollback platform events example with Savepoint
List<PlatformEvents__e > events = new List<PlatformEvents__e >();
// Created a PlatformEvents with a Message__c field of 30 characters only, so second event fails
events.add(new PlatformEvents__e(Message__c='Test'));
events.add(new PlatformEvents__e(Message__c='ldjgkfjgkfjkjhkgjhkgjhkghkghkgkhkghkghkghkghkghghkghkghkghkghghkghkghkghkghghkghkghkghkghghkghkghkghkghghkghkghkghkgh'));
Savepoint sp = Database.setSavepoint();
// Call method to publish events
List<Database.SaveResult> results = EventBus.publish(events);