Skip to content

Instantly share code, notes, and snippets.

@sfboss
sfboss / PivotalTrackerUpdatePayload.cls
Created July 28, 2022 03:39
Example payload from Pivotal Tracker Rest API
global class PivotalTrackerUpdatePayload {
public enum kindTypes { pull_request_create_activity, pull_request }
public class New_values {
public Long accepted_at;
public Integer before_id;
public Integer after_id;
public String current_state;
public Long updated_at;
@sfboss
sfboss / PivotalTrackerEndpoint.cls
Created July 31, 2022 06:35
APEX REST for Pivotal Tracker Webhook
/**
* @description : this is a class that will be setup in a Salesforce Experience Site as a public API that can accept data from Pivotal Tracker
* @author : copyright sfdcboss.com
*/
@RestResource(urlMapping = '/handleInboundPayload/*')
/*
Defined in PivotalTrackerUpdatePayload but posting here for reference as well. This is the structure we can expect from the PT Webhooks.
kind
— The value of 'kind' will reflect the specific type of activity that an activity resource represents. The value will be a string that ends in '_activity' and which starts with a name based on the change which occurred. This field is read only.
guid
/**
* @description : this is a class that will be setup in a Salesforce Experience Site as a public API that can accept data from Pivotal Tracker
* @author : copyright sfdcboss.com
*/
@RestResource(urlMapping = '/handleInboundPayload/*')
/*
Defined in PivotalTrackerUpdatePayload but posting here for reference as well. This is the structure we can expect from the PT Webhooks.
kind
— The value of 'kind' will reflect the specific type of activity that an activity resource represents. The value will be a string that ends in '_activity' and which starts with a name based on the change which occurred. This field is read only.
guid
public with sharing class customApprovalsController {
@AuraEnabled
public static List<wrapperClass> getApprovals(String theType, String theCommentFilter){
List<wrapperclass> theApprovals = getPendingList(theType, theCommentFilter);
return theApprovals;
}
public with sharing class customApprovalsController {
@AuraEnabled
public static List<wrapperClass> getApprovals(String theType, String theCommentFilter){
List<wrapperclass> theApprovals = getPendingList(theType, theCommentFilter);
return theApprovals;
}
public with sharing class bCheckController {
@AuraEnabled
public static Boolean approveDC(Id theDCId){
//Class used for Approving Record
try {
Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
req.setComments('Approving request for DC');
//Approve or Reject Record
@sfboss
sfboss / reddit_po1_2
Last active September 5, 2022 04:38
Power of one example for CASESAFEID use case
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>NO_casesafe_PO1__c</fullName>
<externalId>false</externalId>
<formula>IF($User.Id == User__c,1,0)</formula>
<formulaTreatBlanksAs>BlankAsZero</formulaTreatBlanksAs>
<label>NO casesafe PO1</label>
<precision>18</precision>
<required>false</required>
<scale>0</scale>
@sfboss
sfboss / salesforce and pivotal tracker integration
Created September 6, 2022 03:51
JSON payload for Activity Update
[
{
"kind": "iteration_update_activity",
"guid": "123",
"project_version": 66,
"message": "Wilhuff Tarkin changed iter",
"highlight": "changed",
"changes": [
{
"kind": "iteration_override",
@sfboss
sfboss / oauth_handler.cls
Created September 7, 2022 01:34
OAuth generic handler to get access token and parse based on key/secret and credentials hardcoded or custom setting'ed
public class RRSign_OAUTH_Handler implements Schedulable, Database.AllowsCallouts {
public void execute(SchedulableContext SC){
run();
}
@future(callout=true)
public static void run(){
String endpoint = 'https://test.salesforce.com/services/oauth2/token';
// or use this endpoint for a sandbox org:
// String endpoint='https://test.salesforce.com/services/oauth2/token';
@sfboss
sfboss / niavcContent
Last active September 24, 2022 05:08
LatestforFilesExport
for i in $(cat ./filesOutput/logs/content_docs_ids.txt); do
firstthreechars=${i:0:3}
# poor mans way of checking if the line in our file is a contentdocumentid
if [ $firstthreechars = '069' ];then
echo 'downloading record '$i
# bunch of string parsing and querying to get what we need
thequerycontent="select ContentDocument.owner.name,ContentDocument.owner.id,linkedentityid,contentdocumentid,linkedentity.type,linkedentity.name,contentdocument.title,contentdocument.fileextension,id from contentdocumentlink where contentdocumentid = '"${i}"'"
thejson=$(sfdx force:data:soql:query -q "$thequerycontent" -u $1 --json | ./jq-win64.exe '.result.records')