Skip to content

Instantly share code, notes, and snippets.

@infocynic
infocynic / knockout-3.0.0.aspnet-bindings.js
Last active September 22, 2015 18:45
Adds Knockout 3 bindings for rendering ASP.Net MVC input and validation markup for indexed primitive and complex types.
// Assigns an ASP.Net MVC-style name attribute to a form field that is part of a list.
// Used inside a foreach: binding.
// Example for an indexed primitive type (string, int, etc.) :
// <div data-bind="foreach: Items">
// <input type="text" data-bind="value: SomeValue, aspnetIndexedName: 'Items'" />
// </div>
//
// The above will name the input fields "Items[0]", "Items[1]", etc. For a complex type,
// a property can be specified in addition to the name:
// <div data-bind="foreach: Items">
@infocynic
infocynic / TranslationFun.md
Created October 11, 2022 13:25
Salesforce translations

Translations

Fair warning: Translations in Salesforce are painful. This is the least bad option I could find and I spent 4 hours working on this in May 2020. -InfoCynic

A word to admins and devs

Please avoid putting special characters or commas into the API names of picklist values. If you make a picklist value that has special characters, please edit it afterward to change the API name to something safer. This will greatly reduce the time it takes to make working translation files.

Software required

Microsoft Excel Any text editor capable of changing the file encoding; e.g. Notepad++

@infocynic
infocynic / SalesforceIntegrationLicenseHOWTO.md
Last active May 15, 2024 14:36
How to use Salesforce Integration User Licenses

How to make an integration user using the new licenses that became available in April 2023:

If you want to just do it the "easy" way and have the minimum number of PSets, completely bespoke for this integration:

  1. Make a user with the Minimum Access - API Only Integration Profile.
  2. Create a new Permission set that has the "Salesforce API Integration" license. There is a very similarly named license that will not work. Be sure you are using this one. Add all the permissions you need in this pset.
  3. If you are working with packages like Salesforce CPQ, you may need to make additional PSets that have Permission Set Licenses. Those permission sets cannot apply App or System Permissions. **You cannot use any Permission Set that requires a different User License, such as "Salesforce."
  4. Assign this/these Pset(s) to the user
  5. Assign the Integration PSL to that user
@infocynic
infocynic / SyncDelegateGroupFromRole.ps1
Created June 14, 2023 17:55
Use SF CLI to sync members of a DelegateGroup from a Role
param (
[Parameter(Mandatory = $true, HelpMessage = "Specify the target org alias or username.")]
[string]$targetOrg,
[Parameter(Mandatory = $true, HelpMessage = "Specify the DeveloperName of the DelegateGroup.")]
[string]$delegateGroup,
[Parameter(Mandatory = $true, HelpMessage = "Specify the DeveloperName of the Role.")]
[string]$roleName
)
@infocynic
infocynic / generateGitIgnore.ps1
Last active June 28, 2023 13:09
Generate .gitignore for common components of managed SF packages
param (
[Parameter(Mandatory = $true, HelpMessage = "Specify the target org alias or username.")]
[string]$targetOrg
)
param (
[Parameter(Mandatory = $true, HelpMessage = "Specify the root directory for the metadata; e.g., force-app/main/default.")]
[string]$rootDir
)
@infocynic
infocynic / SUB_GetUsersWithCustomPermission.flow-meta.xml
Created October 4, 2023 20:20
Subflow to find users with a custom permission
<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<assignments>
<description>Add the current PSet Id from the Record (ParentId) to the Text list</description>
<name>Add_PSet_Id_to_List</name>
<label>Add PSet Id to List</label>
<locationX>264</locationX>
<locationY>458</locationY>
<assignmentItems>
@infocynic
infocynic / ContractTriggerHandler.cls
Created March 29, 2024 13:20
Apex Trigger Handler for Bucketing Contacts
//this class assumes you are running in a trigger context. it would be better to inherit from a base trigger class and replace
//the reference on line 11 with that.
public without sharing class ContactTriggerHandler {
private map<string, id> saMap = new Map<string, id>();
public static final Integer keyLength = 2;
// Constructor
public ContactTriggerHandler() {
//better: replace static reference to trigger with something from a base handler