Last active
April 22, 2022 18:12
-
-
Save jvolkov/7f4a0253303b6c0758116219d89d31be to your computer and use it in GitHub Desktop.
vs-code-snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
//For List | |
"List_Apex": { | |
"prefix": "listToUpdate", | |
"body": [ | |
"List<${1:object}> ${2:lstName} = new List<${1}>();" | |
], | |
"description":"List of sObjects" | |
}, | |
// for set | |
"Set_Apex": { | |
"prefix": "set<", | |
"body": [ | |
"Set<${1:key}> ${2:setName} = new Set<${1}>();" | |
], | |
"description":"Set of sObjects" | |
}, | |
// for map | |
"Map_Apex": { | |
"prefix": "map<", | |
"body": [ | |
"Map<${1:key}, ${2:value}> ${3:mapName} = new Map<${1}, ${2}>();" | |
], | |
"description":"Map of sObjects" | |
}, | |
// for each loop | |
"apex_for_update": { | |
"prefix": "for(", | |
"body": [ | |
"List<${1:object}> ${1}sToUpdate = new List<${1}>();", | |
"for (${1} ${2:varName}: ${1}s) {", | |
" // do stuff", | |
" ${1}sToUpdate.add(${2});", | |
"}", | |
"// Database.SaveResult[] results = Database.update(${1}sToUpdate, false);" | |
], | |
"description": "Apex For Loop Update" | |
}, | |
// soql apex | |
"soql_Apex": { | |
"prefix": "list soql", | |
"body": ["List<$1> $2 = [SELECT $3 $0 FROM $1];"], | |
"description": "SOQL query assignment to List variable" | |
}, | |
// public method | |
"public_static_method": { | |
"prefix": "method", | |
"body": ["public static ${1:returnType} ${2:methodName} (${3:params}) {}"], | |
"description": "public static method" | |
}, | |
// cached soql list | |
"cached_soql": { | |
"prefix": "cache", | |
"body": [ | |
"private static List<${1:object}> get${1}s() {", | |
" List<${1}> ${1}s = [SELECT Id FROM ${1} WHERE CreatedDate = today]; ", | |
" return ${1}s;", | |
"}", | |
"private static List<${1}> ${1}s = get${1}s();" | |
], | |
"description": "returns a cached soql list" | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// import an object and field for a lightning web component | |
"html_comment": { | |
"prefix": "comment", | |
"body": [ | |
"<!-- ${1:comment} -->" | |
], | |
"description": "make a comment" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @description: javascript shortcuts | |
* use ${1:variable} format for binding | |
*/ | |
{ | |
// import an object and field for a lightning web component | |
"import_field": { | |
"prefix": "import field", | |
"body": [ | |
"import ${1:UPPER}_OBJECT from '@salesforce/schema/${2:CamelObject}';", | |
"import ${3:UPFER_FIELD}_FIELD from '@salesforce/schema/${2:CamelObject}.${4:CamelField}';", | |
], | |
"description": "import a field" | |
}, | |
// assign data and error values from @wire service | |
"wire_if": { | |
"prefix": "@wire(", | |
"body": [ | |
"@wire(${1:IMPORT_DATA}, { ${2:idVar}: '$recordId' })", | |
"wiredContacts({ error, data }) {", | |
" if (data) {", | |
" this.${3:dataVar} = data;", | |
" this.${4:errorVar} = undefined;", | |
" } else if (error) {", | |
" this.${4:errorVar} = error;", | |
" this.${3:dataVar} = undefined;", | |
" }", | |
"}", | |
], | |
"description": "@wire data and error variable " | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* use ${1:variable} | |
*/ | |
{ | |
// for lightning web component config files | |
// specifically for use in the flow builder | |
"target_configs": { | |
"prefix": "targetConfig", | |
"body": [ | |
"<targetConfigs>", | |
" <targetConfig targets=\"lightning__FlowScreen\">", | |
" <property name=\"recordId\" type=\"String\"/>", | |
" </targetConfig>", | |
"</targetConfigs>" | |
], | |
"description": "targetConfigs for flow screen" | |
} | |
"targets": { | |
"prefix": "targets", | |
"body": [ | |
"<targets>", | |
" <target>lightning__AppPage</target>", | |
" <target>lightning__RecordPage</target>", | |
" <target>lightning__HomePage</target>", | |
" <target>lightning__FlowScreen</target>", | |
"</targets>" | |
] | |
"description": "targets to deploy anywhere " | |
} | |
"help": { | |
"prefix": "help", | |
"body": [ | |
"<inlineHelpText>${1:help}</inlineHelpText>" | |
] | |
"description": "inline help text for use in a flow component" | |
} | |
// for field formulas | |
"ischanged": { | |
"prefix": "ischanged(", | |
"body": [ | |
"AND(", | |
" OR(", | |
" ISNEW(),", | |
" ISCHANGED(${1:field__c})" | |
" )" | |
")" | |
] | |
"description": "check if field changed" | |
} | |
"formulaField": { | |
"prefix": "formula field", | |
"body": [ | |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>", | |
"<CustomField xmlns=\"http://soap.sforce.com/2006/04/metadata\">", | |
" <fullName>${1:Field_Name__c}</fullName>", | |
" <externalId>false</externalId>", | |
" <formula>IF(logic,true,false)</formula>", | |
" <formulaTreatBlanksAs>BlankAsZero</formulaTreatBlanksAs>", | |
" <label>${2:Field Label}</label>", | |
" <required>false</required>", | |
" <type>Text</type>", | |
" <unique>false</unique>", | |
"</CustomField>" | |
] | |
"description": "create new formula field" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment