Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Szandor Knapp Szandor72

View GitHub Profile
@Szandor72
Szandor72 / basic VF Extension template
Created May 24, 2017
basic VF Extension template
View basic VF Extension template
public with sharing class AccountExtensionController
{
private ApexPages.StandardController standardController;
public AccountExtensionController(ApexPages.StandardController standardController)
{
this.standardController = standardController;
}
public void nextStep(){
View runAs Profile test class for quote and folders
@istest(seealldata=true)
public class testLEXProfileForQuote {
    @istest
    public static void test() {
        String quoteId = 'a0O9E000000WDDf';
        User myUser = [select id, name from user where ProfileId = '00e9E000000HlA4' and lastname = 'Brückner' and isactive=true limit 1];
        sf42_quotefx__Sf42_quote__c quote = null;
        system.debug(myUser);
        System.runAs(myUser){
            quote = [ Select
@Szandor72
Szandor72 / js
Created Jul 14, 2017
diff javascript
View js
Array.prototype.rotate = function(n){
var len = this.length,
res = new Array(this.length);
if (n % len === 0) return this.slice();
else for (var i = 0; i < len; i++) res[i] = this[(i + (len + n % len)) % len];
return res;
};
String.prototype.diff = function(s,p){ // p -> precision factor
@Szandor72
Szandor72 / ps1
Last active Oct 3, 2017
ForceCode: Generate and set Credentials for Scratch Orgs (Powershell)
View ps1
sfdx force:user:password:generate
$myOrg = (sfdx force:org:display --json | ConvertFrom-Json).result
$forceConfig = Get-Content .\force.json -Raw | ConvertFrom-Json
$forceConfig.url = $myOrg.instanceUrl
$forceConfig.username = $myOrg.username
$forceConfig.password = $myOrg.password
$forceConfig.apiVersion = "40.0"
$forceConfig | ConvertTo-Json | Out-File -FilePath force.json -Encoding utf8
@Szandor72
Szandor72 / findDupes
Created Oct 25, 2017 — forked from goravseth/findDupes
invocable apex to find duplicate contacts using the new findDuplicates apex stuff
View findDupes
public class Flow_FindDupes {
//https://developer.salesforce.com/forums/?id=906F0000000AzDeIAK
@InvocableMethod(label='Get Dupes' description='Returns something')
public static List<Contact> getDuplicateContacts(List<Contact> contacts) {
system.debug('contacts size = ' + contacts.size());
list<sObject> dasContacts = new list<sobject>();
dasContacts.addall((List<sObject>)(contacts));
list<Contact> duplicateContacts = new list<Contact>();
View dealing with different sObjects in one List
List<String> sObjectNames = new String[]{'Account','Contact','opportunity'};
List<sObject> queriedObjects = new List<Sobject>();
For (String sObjectName : sObjectNames) {
//Querying for objects in a loop is bad practice
sObject tempObject = Database.query('Select Id, Name From ' + sObjectName + ' Limit 1');
queriedObjects.add(tempObject);
}
View Security Review Pseudo Code Example
// .... //
myObject__c myObject = new myObject__c();
myObject.field1__c = 'abc';
myObject.field2__c = 'def';
List<String> objFields = new List<String> {'field1__c', 'field2__c'}
@Szandor72
Szandor72 / exception
Created Feb 24, 2018
Codec Error on deploy
View exception
2018-02-24 22:16:41: Running task: deploy
2018-02-24 22:16:41: Options:
2018-02-24 22:16:41: path: src
2018-02-24 22:16:41: Beginning task: Deploy
2018-02-24 22:16:41:
2018-02-24 22:16:42: Cleaning meta.xml files of packageVersion elements for deploy
2018-02-24 22:16:42: Task failed: deploy
2018-02-24 22:16:42: Failing flow due to exception in task
Traceback (most recent call last):
File "/root/virutalenvironments/cumulusci/local/lib/python2.7/site-packages/cumulusci/core/flows.py", line 191, in _run_task
View source pull
C:\Users\szand\OneDrive\dev\mediavelox [master ↑]> sfdx force:source:status -r -u mvx
=== Source Status
STATE FULL NAME TYPE PROJECT PATH
────────────── ──────────────────────────────────────────────── ─────────────────────── ──────────────────────────────────────────────────────────────────────────────────────────────────────
Remote Changed DispoBlockedItems__c.AdPos_Catalog__c CustomField mediavelox\main\default\objects\DispoBlockedItems__c\fields\AdPos_Catalog__c.field-meta.xml
Remote Changed DispoBlockedItems__c.DispoBookEntry__c CustomField mediavelox\main\default\objects\DispoBlockedItems__c\fields\DispoBookEntry__c.field-meta.xml
Remote Changed Account.MVX_PreferredNumberOfProofsOfDelivery__c CustomField mediavelox\main\default\objects\Account\fields\MVX_PreferredNumberOfProofsOfDelivery__c.field-meta.xml
Remote Changed AdPosCatalog__c.AdPosition__c
@Szandor72
Szandor72 / lts-unit-test.MD
Created Apr 20, 2018 — forked from sjurgis/lts-unit-test.MD
How to do actual unit testing in Lightning Testing Service
View lts-unit-test.MD

Expose helper via an public aura:method function in your abstract component's testHelperController.js:

getHelper: function(component, event, helper) {
 if ( $T ) {
  return helper;
 } else {
  throw new Error('API is only supported in test context');
 }
}