Skip to content

Instantly share code, notes, and snippets.

View keirbowden's full-sized avatar

Keir Bowden keirbowden

View GitHub Profile
@keirbowden
keirbowden / QRCode.page
Last active November 11, 2019 14:46
Salesforce1 QR Code Reader
<apex:page >
<script type="text/javascript"
src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="{!URLFOR($Resource.QRCode, 'jsqrcode-master/src/grid.js')}"></script>
<script type="text/javascript" src="{!URLFOR($Resource.QRCode, 'jsqrcode-master/src/version.js')}"></script>
<script type="text/javascript" src="{!URLFOR($Resource.QRCode, 'jsqrcode-master/src/detector.js')}"></script>
<script type="text/javascript" src="{!URLFOR($Resource.QRCode, 'jsqrcode-master/src/formatinf.js')}"></script>
<script type="text/javascript" src="{!URLFOR($Resource.QRCode, 'jsqrcode-master/src/errorlevel.js')}"></script>
<script type="text/javascript" src="{!URLFOR($Resource.QRCode, 'jsqrcode-master/src/bitmat.js')}"></script>
@keirbowden
keirbowden / SigCapFlowWithFinishController.js
Created October 29, 2019 10:44
Aura component controller to handle flow navigation.
({
handleCaptured : function(component, event, helper)
{
console.log('Captured signature')
let flowAction=null;
let availableActions=component.get('v.availableActions');
console.log('Available actions = ' + availableActions);
for (let idx=0; idx<availableActions.length && null==flowAction; idx++) {
let availAction=availableActions[idx];
if ('NEXT'==availAction) {
@keirbowden
keirbowden / SigCapFlowWithFinish.cmp
Created October 29, 2019 10:41
Aura component to handle flow navigation.
<aura:component implements="lightning:availableForFlowScreens">
<aura:attribute access="global" name="startMsg" type="String" default="Click the 'Capture Signature' button to begin"
description="Message to display to the user to start the signature capture process"/>
<aura:attribute access="global" name="enterMsg" type="String" default="Sign here please"
description="Text to display above the signature capture canvas" />
<aura:attribute access="global" name="completeMsg" type="String" default="Here is the captured signature"
description="Text to display above the image of the captured signature once it has been saved to the server"/>
<aura:attribute access="global" name="recordId" type="String"
description="The id of the record to attach the signature to"/>
<aura:attribute access="global" name="saveAttachment" type="Boolean" default="true"
@keirbowden
keirbowden / tasks.json
Last active July 13, 2019 07:22
VSCode task file to execute
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "node",
"args": [
"deploy.js"
],
"problemMatcher": [ {
@keirbowden
keirbowden / deploy.js
Created January 26, 2018 08:51
Simple node script to execute a deployment via SFDX and capture and output any errors that occurred
#!/usr/local/bin/node
var fs=require('fs');
var child_process=require('child_process');
var username='keir.bowden@googlemail.com';
var deployParams=['force:mdapi:deploy', '-d', 'src',
'-u', username, '--json'];
@keirbowden
keirbowden / animatedBar.js-meta.xml
Created April 6, 2019 16:05
XML Metadata for the Animated Bar Lightning Web Component
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="animatedBar">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
@keirbowden
keirbowden / animatedBar.js
Created April 6, 2019 16:04
JavaScript for the Animated Bar Lightning Web Component
/* eslint-disable no-console */
import { LightningElement, track } from 'lwc';
export default class AnimatedBar extends LightningElement {
@track value = 0;
handleInputValueChanged(event) {
window.clearTimeout(this.delayTimeout);
const final = event.target.value;
@keirbowden
keirbowden / animatedBar.html
Created April 6, 2019 16:02
Animated Progress Bar Lightning Web Component Markup
<template>
<div class="slds-m-around_small">
<div class="slds-text-heading_large slds-m-bottom_small">Progress Bar Demo</div>
<div class="slds-m-bottom_large">
<label>Enter value : <lightning-input type="number" name="seven" value="0" placeholder="Enter the amount..." onchange={handleInputValueChanged}></lightning-input></label>
</div>
<div>
<div style="width:25%" class="slds-progress-bar slds-progress-bar_circular slds-progress-bar_large"
aria-valuemin="0" aria-valuemax="100" aria-valuenow={amount} role="progressbar">
<span class="slds-progress-bar__value" style={width}>
@keirbowden
keirbowden / deploy_with_exit_codes.js
Created April 16, 2018 12:39
Node script to execute a deployment and return 0 for success or 1 for failure.
#!/usr/local/bin/node
var fs=require('fs');
var child_process=require('child_process');
var username='keir.bowden@sfdx.deploy';
var deployParams=['force:mdapi:deploy', '-d', 'Orchestrate/src',
'-u', username, '--json'];
@keirbowden
keirbowden / AccountController.cls
Created December 12, 2015 16:10
Apex controller from the Lightning Component Wrapper Classes blog post
public with sharing class AccountController
{
@AuraEnabled
public static List<Account> GetAccountNames()
{
return [select id, Name from Account limit 10];
}
@AuraEnabled
public static List<Account> GetAccountDetails(String idListJSONStr)