Skip to content

Instantly share code, notes, and snippets.

View sjurgis's full-sized avatar

Jurgis Šalna sjurgis

  • Auckland, New Zealand
View GitHub Profile
public with sharing class OpportunitiesSelector {
@AuraEnabled public static Object[] getByNames(String[] names) {
Contact[] contacts = [SELECT Id FROM Contact WHERE Name = :names];
Account[] accounts = [SELECT Id FROM Account WHERE Id IN (SELECT AccountId FROM Contact WHERE Id = :contacts)];
Opportunity[] opportunities = [SELECT Id FROM Opportunity WHERE AccountId = :accounts];
return new Object[]{
contacts,
accounts,
opportunities
};
@sjurgis
sjurgis / open-lwc.sh
Created August 10, 2022 11:03
open lwc component without isUrlAddressable
res=$(echo 'console.log(btoa(JSON.stringify({"componentDef" : "c:'$1'","attributes" :{"recordId" : "0031F00000rMHfAQAW","testAttribute" : "attribute value"}})))' | node)
url=/one/one.app#$res
echo $url
sfdx force:org:open -r -p $url --json | jq -r .result.url
public with sharing class ModalList {
ApexPages.StandardSetController setCon;
public PageReference init() {
List<Id> ids = new List<Id>();
for (SObject i : this.setCon.getSelected()) {
ids.add((String)i.get('Id'));
}
return new PageReference(
String.format('/lightning/cmp/c__ModalWrapper?c__ids={0}&c__returnUrl={1}', new String[]{
String.join(ids, ','),
@sjurgis
sjurgis / eso.html
Created August 6, 2023 11:11
ESO CSV plotteris (valandinis)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interactive CSV Plotter</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
@sjurgis
sjurgis / PDFPrinter.cls
Created June 20, 2024 00:53
Print multiple record detail pages as PDF (Salesforce Apex Visualforce)
public inherited sharing class PDFPrinter {
public static String getContent() {
String[] ids = ApexPages.currentPage().getParameters().get('ids').split(',');
// TODO do record access checks!
String content = '';
for (String i : ids) {
PageReference p = new PageReference('/' + i + '/p');
content += p.getContent().toString();
}
content = content
@sjurgis
sjurgis / limits.sh
Created June 29, 2024 00:41
One liner to display Salesforce org limits that are under 100%
sf org list limits --json | node -e "JSON.parse(require('fs').readFileSync(0,'utf-8')).result.filter(i=>i.remaining<i.max).forEach(i=>console.log(\`\${i.name}: \${((i.remaining/i.max)*100).toFixed(2)}% remaining\`))"