Skip to content

Instantly share code, notes, and snippets.

@and0ne808
and0ne808 / imgReplace.js
Created June 3, 2020 18:07
Add placeholder image if there is an image error
//Add a placeholder image on img load error using jQuery
$("img").on('error', function () {
$(this).attr("src", "https://www.imgServer.com/myExampleImgURL.jpg");
});
@and0ne808
and0ne808 / Code.apxc
Created March 4, 2020 01:22
Script to populate product categories in CloudCraze - 3 levels deep
//CHANGE THESE
String family = 'Tissue Expanders';
String category = 'Miscellaneous';
String subcategory = 'Accessory Items';
ccrz__E_Category_c cat = [SELECT Id, Name, ccrz_ParentCategory_r.Name, ccrz_ParentCategory_r.ccrz_ParentCategory_r.Name FROM ccrz_E_Category__c WHERE
Name = :subcategory AND
ccrz_ParentCategory_r.Name = :category AND
ccrz_ParentCategory_r.ccrz_ParentCategory_r.Name = :family
LIMIT 1];
List<ccrz__E_ProductCategory_c> existingProdCats = [SELECT Id, ccrz_Product_c, ccrz_Category_c FROM ccrz_E_ProductCategory_c WHERE ccrz_Category__r.Id = :cat.Id];
@and0ne808
and0ne808 / RLWS_LC_BackToB2BHome.cmp.html
Created April 12, 2018 22:40
Salesforce Lightning Dynamic Back Button Component
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global">
<aura:attribute name="url" type="String" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<ui:outputURL aura:id="url" value="{!v.url}" label = "Back To Home" />
</aura:component>
@and0ne808
and0ne808 / AutoPlayVid.vfc.html
Created April 12, 2018 22:20
Salesforce Files Video Player
<!-- This component displays and autoplays a mp4 video from the Asset Library -->
<apex:component controller="autoPlayVidController">
<apex:attribute name="vidName" description="This is the name of the mp4 video in Asset Library" type="String" required="required" assignTo="{!userInput}"/>
<apex:attribute name="width" description="This is the width of the video in pixels." type="Integer" required="required" />
<apex:attribute name="height" description="This is the height of the video in pixels." type="Integer" required="required"/>
<!-- BEGIN DEBUG SECTION----------------------------------------->
<!--
<h3>DEBUG SECTION</h3>
<p>vidSource: {!vidName}</p>
@and0ne808
and0ne808 / InputStatusHelper.js
Created November 26, 2017 21:50
InputStatusHelper.js - Lightning Component Helper File. Implements the actual functions.
({
insertNewStatus : function(component) {
//Get the Apex function you want to call
var action = component.get("c.insertStatus");
//Set the params for the function
action.setParams({
text : component.get("v.status")
});
@and0ne808
and0ne808 / InputStatusController.js
Created November 26, 2017 21:45
InputStatusController.js - Javascript Controller
({
doInit : function(component, event, helper) {
helper.loadStatuses(component);
},
submitStatusButtonClick : function(component, event, helper) {
helper.insertNewStatus(component);
}
})
@and0ne808
and0ne808 / InputStatus.xml
Last active November 26, 2017 21:41
InputStatus.cmp - Lightning Component
<aura:component controller="StatusService">
<aura:attribute name="status" type="String" />
<aura:attribute name="statuses" type="String[]" />
<!-- fetch the statuses when the component initializes -->
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<p>Input New Status:</p>
<ui:inputTextArea value="{!v.status}" />
@and0ne808
and0ne808 / StatusService.java
Last active November 26, 2017 21:59
StatusService.apxc
public with sharing class StatusService {
@AuraEnabled
public static List<Status__c> getStatuses() {
return [SELECT Name, StatusText__c, CreatedDate
FROM Status__c ORDER BY CreatedDate DESC LIMIT 10]; }
@AuraEnabled
public static List<Status__c> insertStatus(String text) {
Status__c myStatus = new Status__c();
@and0ne808
and0ne808 / ExamTakingApp.app
Created November 26, 2017 03:15
ExamTakingApp.app
<aura:application >
<c:StatusPage />
</aura:application>
@and0ne808
and0ne808 / StatusPageController.js
Created November 26, 2017 03:03
StatusPageController.js
({
doInit : function(component, event, helper) {
let action = component.get('c.getStatuses');
action.setParams({
accountId: '123',
someOtherParameter: 'value'
});
//Callback executed after server action returns
action.setCallback(this, function(response) {