Skip to content

Instantly share code, notes, and snippets.

Peter Knolle peterknolle

Block or report user

Report or block peterknolle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
peterknolle / inputFieldIssue.html
Last active Apr 17, 2019
Shows the lightning-input-field not working after user input. (1): Click the button and see the lightning-input-field get updated. (2) Manually type something into the lightning-input-field and see it change. (3) Go back and click the button and see the update no longer work.
View inputFieldIssue.html
field-name="Name" value={name}></lightning-input-field>
<lightning-button label="Click to change name" variant="brand" onclick={handleClick}></lightning-button>
View Apex is Pass By Value (exec anon)
* Everything is pass by value in Apex.
* When a method is called the runtime pushes a stackframe on the stack and params
* are created as local vars, including ref vars.
* The object that the ref var points to lives on the heap and can be modified if not immutable.
* The param itself is the ref var and is by value like all params in Apex.
public class A {
public String val { get; set; }
peterknolle / inputRating.cmp
Last active Jun 25, 2019
Input Rating Lightning Component
View inputRating.cmp
<aura:component >
<ltng:require scripts="/resource/rating/vendor/jquery.js,/resource/rating/lib/jquery.raty.js"
<aura:attribute name="value" type="Integer" required="true"/>
<aura:attribute name="ready" type="Boolean" default="false"/>
<div aura:id="rating"></div>
View RestRequestController.cls
public class RestRequestController {
public static Response service(String path, String method, String responseFormat, String bodyContent, String bodyContentType) {
HttpRequest request = buildRequest(path, method, responseFormat, bodyContent, bodyContentType);
HttpResponse httpRes = sendRequest(request);
Response restRes = buildResponse(httpRes);
return restRes;
peterknolle / fileSelected.evt
Last active Jan 18, 2019
Image Preview Lightning Component
View fileSelected.evt
<aura:event type="COMPONENT" description="Event fired when a file is selected">
<aura:attribute name="file" type="Object"
description="The file file input element that has the selected file"/>
peterknolle / FileController.cls
Last active Jul 13, 2019
Lightning File Upload Component
View FileController.cls
public class FileController {
public static Id saveTheFile(Id parentId, String fileName, String base64Data, String contentType) {
base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
Attachment a = new Attachment();
a.parentId = parentId;
a.Body = EncodingUtil.base64Decode(base64Data);
peterknolle / AutocompleteController.cls
Last active Jul 25, 2018
Lightning Autocomplete Component
View AutocompleteController.cls
public class AutocompleteController {
public static List<sObject> getSuggestions(String sObjectType, String term, String fieldsToGet, Integer limitSize) {
// could add in logic to remove possible duplicate fields
String fields = fieldsToGet.length() > 0 ? ',' + fieldsToGet : '';
String soql =
' SELECT Name, Id ' + String.escapeSingleQuotes(fields) +
' FROM ' + String.escapeSingleQuotes(sObjectType) +
' WHERE Name Like \'' + String.escapeSingleQuotes(term) + '%\'' +
peterknolle /
Created Oct 1, 2014
Remote Objects Autocomplete
<apex:page >
<link rel="stylesheet" href="//" />
<script src="//"></script>
<script src="//"></script>
<apex:remoteObjects >
<apex:remoteObjectModel name="Contact" fields="Name,Id,Email,MobilePhone,Phone"/>
peterknolle / ContactsController.cls
Last active Mar 30, 2017
Remote Objects Infinite Scroll
View ContactsController.cls
public with sharing class ContactsController {
public static Map<String, Object> retrieveContacts(String type, List<String> fields, Map<String, Object> criteria) {
// Retrieve using the standard retrieve
Map<String, Object> result = RemoteObjectController.retrieve(type, fields, criteria);
// Add in the total record count for the current user.
// This is needed to know when to stop scrolling.
peterknolle / CORS_MessageService.cls
Last active Aug 29, 2015
Accessing Apex REST from
View CORS_MessageService.cls
global class MessageService {
global static void getMessages() {
// buildMessages gets FeedItems
List<Message> messages = buildMessages();
RestResponse res = RestContext.response;
You can’t perform that action at this time.