Skip to content

Instantly share code, notes, and snippets.

View sjurgis's full-sized avatar

Jurgis Šalna sjurgis

  • Auckland, New Zealand
View GitHub Profile
@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\`))"
@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 / 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>
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 / 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 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 / cal.html
Last active August 26, 2024 11:08
full calendar in umd format (for lwc)
<template>
<div class="slds-card">
<div class="fullcall" lwc:dom="manual"></div>
</div>
</template>
@sjurgis
sjurgis / Main.cmp
Created February 14, 2022 00:29
lightning aura component tabset with url navigation
<aura:component implements="force:appHostable, lightning:hasPageReference" >
<lightning:navigation aura:id="navigation"/>
<lightning:tabset variant="vertical" selectedTabId="{!v.pageReference.state.c__tab}">
<lightning:tab label="Item One" id="one" onactive="{!c.handleActive}">
First
</lightning:tab>
<lightning:tab label="Item 2" id="two" onactive="{!c.handleActive}">
second
</lightning:tab>
<lightning:tab label="Item 3" id="three" onactive="{!c.handleActive}">
@sjurgis
sjurgis / main.html
Created February 9, 2022 09:05
lightning web component tabset with url navigation
<template>
<lightning-tabset variant="vertical" active-tab-value={activeTabValue}>
<lightning-tab label="Item One" value="one" onactive={handleActive}>
First
</lightning-tab>
<lightning-tab label="Item 2" value="two" onactive={handleActive}>
second
</lightning-tab>
<lightning-tab label="Item 3" value="three" onactive={handleActive}>
third
@sjurgis
sjurgis / testBetaRelease.sh
Last active December 8, 2021 15:15
salesforce second generation package create, install and test using github actions
#!/bin/bash
set -e
set -o pipefail
CLIENT_ID=$1
rm -f ./server.key
cat > ./server.key
sfdx auth:jwt:grant --setdefaultusername --clientid "$CLIENT_ID" --jwtkeyfile ./server.key --username [email protected] -a HubOrg
mv .forceignore .forceignore.orig