Skip to content

Instantly share code, notes, and snippets.

View ruslan-kurchenko's full-sized avatar
💭
🙌 on 🔥 while 👨‍💻

Ruslan Kurchenko ruslan-kurchenko

💭
🙌 on 🔥 while 👨‍💻
View GitHub Profile
@ruslan-kurchenko
ruslan-kurchenko / bin.sh
Last active January 14, 2025 16:41
Salesforce | Enable Service Presence Status Access for a permission set
# A terminal should be connected to the org using SFDX CLI!
# dev - the name of the org
# Omni_Channel_Presence_Statuses - the name of the permission set
# "Available for Cases,Away,Missed Cases" - the list of statuses to enable
node index.js dev Omni_Channel_Presence_Statuses "Available for Cases,Away,Missed Cases"
@ruslan-kurchenko
ruslan-kurchenko / start_multiple_radicle_nodes.shell
Last active March 3, 2021 22:42
Start multiple Radicle seed nodes
#!/bin/bash
# Initial server setup and dependencies installation
apt-get update
apt install curl git gpw ufw -y
# Install RUST and dependencies
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y
source /root/.cargo/env
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
@ruslan-kurchenko
ruslan-kurchenko / useConstantsClass.apex
Created January 22, 2021 10:55
How to use Constants with Amoss & FabricatedSObject libs
Log__c log = (Log__c) new FabricatedSObject()
.set(Constants.Log.SEVERITY, 'ERROR')
.add(Constants.Log.TRANSACTION_STATUS, 'ERROR')
.toSObject();
FieldsRelationship__mdt fieldRel = (FieldsRelationship__mdt) new FabricatedSObject();
.set(Constants.FieldsRelationship.IS_EXTERNAL_ID, true)
.add(Constants.FieldsRelationship.OBJECTS_RELATIONSHIPS, new List<?>())
.toSObject();
@ruslan-kurchenko
ruslan-kurchenko / Constants.cls
Created January 22, 2021 10:46
Constants class with all static values accessible by get properties
public inherited sharing class Constants {
public static Log Log {
get {
return Log == null ? (Log = new Log()) : Log;
}
private set;
}
public static CustomMetadataType CustomMetadataType {
get {
@ruslan-kurchenko
ruslan-kurchenko / StubProviderFactory.cls
Last active April 16, 2019 07:20
The workaround for the case when you need to stub an Apex global class from a managed package
/**
* @description Contains a simple logic to create a stub instance using given <code>Type</code> and actual
* <code>StubProvider</code> concrete instance.
* The main mission of the class to provide a workaround for Apex Stub API Limitations:
* - The object being mocked must be in the same namespace as the call to the Test.createStub() method
*/
@IsTest
global class StubProviderFactory {
global Object createStub(Type type, StubProvider provider) {
component.lax.enqueue('c.save')
.then(result => {
// handle "SUCCESS" save result
})
.error(e => {
// handle "ERROR" save result
// e.name === "ApexActionError"
})
.incomplete(e => {
// handle "INCOMPLETE" save result
// registration in the root:
component.lax.util.registerError(MyCustomError)
// usage in the child components:
const errors = component.lax.errors;
component.lax.enqueue('c.save')
.then(result => {
throw new errors.MyCustomError();
})
.catch(errors.MyCustomError, e => {
// define custom error
function MyCustomError() {}
MyCustomError.prototype = Object.create(Error.prototype);
MyCustomError.prototype.constructor = MyCustomError;
// throw new custom error and handle with .catch
component.lax.enqueue('c.save')
.then(result => {
throw new MyCustomError();
})
function MyCustomError() {}
MyCustomError.prototype = Object.create(Error.prototype);
MyCustomError.prototype.constructor = MyCustomError;
const errors = component.lax.errors;
component.lax.enqueue('c.save')
.then(result => {
// handle "SUCCESS" save result
})
.catch(errors.ApexActionError, e => {
// handle "ERROR" save result
})
.catch(errors.IncompleteActionError, e => {
// handle "INCOMPLETE" save result