Skip to content

Instantly share code, notes, and snippets.

View mhamzas's full-sized avatar

Hamza Siddiqui mhamzas

View GitHub Profile
@mhamzas
mhamzas / Visualforce Remote Objects.js
Last active May 11, 2018 15:06 — forked from dcarroll/gist:8427394
Javascript operations for Visualforce Remote Objects. Totally subject to change as this feature is currently in Developer Preview until Summer '14.
/* PRE - model declaration on vf page
<apex:remoteObjects>
<apex:remoteObjectModel name="Account" fields="Id,Name" />
</apex:remoteObjects>
*/
/* INSTANCE */
// 1. W/o default properties
var acc = new SObjectModel.Account();
@mhamzas
mhamzas / laravel.stpl
Created May 11, 2018 15:05 — forked from inerba/laravel.stpl
Laravel template VESTACP
# /usr/local/vesta/data/templates/web/apache2/laravel.stpl
<VirtualHost %ip%:%web_ssl_port%>
ServerName %domain_idn%
%alias_string%
ServerAdmin %email%
DocumentRoot %sdocroot%/public/
ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
Alias /vstats/ %home%/%user%/web/%domain%/stats/
@mhamzas
mhamzas / MyLoginPage.apexp
Created June 22, 2018 09:13 — forked from ryanguest/MyLoginPage.apexp
Community login page [Visualforce]
apex:page controller="SiteLoginController" id="loginComponent" showheader="false" standardStylesheets="false">
<h1 style="color: gray"> Community Login </h1>
<apex:form id="loginForm" forceSSL="true">
<apex:outputPanel layout="block">
<apex:pageMessages id="error"/>
<apex:outputLabel value="{!$Label.site.username}" for="username"/>
<apex:inputText id="username" value="{!username}"/>
@mhamzas
mhamzas / DeskSample.java
Created September 11, 2018 15:29 — forked from tstachl/DeskSample.java
Example talking to the Desk.com API from Salesforce (Apex).
public class DeskSample
{
private static String OAUTH_KEY = 'youroauthkey';
private static String OAUTH_SECRET = 'youroauthsecret';
private static String ACCESS_TOKEN = 'youraccesstoken';
private static String ACCESS_TOKEN_SECRET = 'youraccesstokensecret';
public static String DESK_SITENAME = 'yoursite';
public static Void doRequest()
@mhamzas
mhamzas / AttachtoParent.trg
Last active March 29, 2019 09:29
Apex Trigger to move Attachment from Task to Parent
//
// Author : M Hamza Siddiqui
// Created Date : 9/14/2018
// Description : Apex Trigger to move Attachment from Task to Parent Object Record (on the basis of WHATID i.e. RelatedTo)
//
// Initializing Trigger when any new attachment get inserted in SF
trigger AttachtoParent on Attachment (after insert) {
List<Attachment> Attachments = new list<Attachment>();
// Looping thorugh the attachments
for (Attachment a : trigger.new){
@mhamzas
mhamzas / proxmox-ve.md
Created April 4, 2019 22:09 — forked from JosefJezek/proxmox-ve.md
Proxmox VE
/*
* Name : CJA Create Order from Opportunity
* Description : This Trigger will create order from opportunity and also add opporutnity products data into the order ITEMS field.
* Date Created : 3/4/2019
* Last Date Modified : 3/4/2019
*
*/
trigger CJACreateOrderFromOpportunity on Opportunity (after update) {
Map<Id, Opportunity> oppIdToObjMap = new Map<Id, Opportunity>();
@mhamzas
mhamzas / shareKnowledgeFilesWithCommunityUsers.apxc
Last active May 17, 2019 09:57
Sharing Knowledge Files with Community Users for Knowledge
trigger shareKnowledgeFilesWithCommunityUsers on ContentDocumentLink (before insert) {
Schema.DescribeSObjectResult r = Knowledge__kav.sObjectType.getDescribe();
String keyPrefix = r.getKeyPrefix();
for(ContentDocumentLink cdl:trigger.new){
if((String.valueOf(cdl.LinkedEntityId)).startsWith(keyPrefix)){
cdl.ShareType = 'I';
cdl.Visibility = 'AllUsers';
}
}
public class CJA_RMtoSFAccCntcts {
//First part
List<Roadmunk_User__c> allRMCntLst = new List<Roadmunk_User__c>();
List<Roadmunk_Account__c> allRMAccLst = new List<Roadmunk_Account__c>();
//Excluded domains set
Set<String> excludDomains = new Set<String>{'gmail.com','hotmail.com', 'yahoo.com'};
List<Account> accToUpsert = new List<Account>();
@mhamzas
mhamzas / BatchApexErrorTrigger.trg
Created August 30, 2019 15:11
Modify an existing batch Apex job to raise BatchApexErrorEvents
trigger BatchApexErrorTrigger on BatchApexErrorEvent (after insert) {
List<BatchLeadConvertErrors__c> List_LeadConvertError = new List<BatchLeadConvertErrors__c>();
for(BatchApexErrorEvent event: trigger.new){
BatchLeadConvertErrors__c lcerror = new BatchLeadConvertErrors__c();
lcerror.AsyncApexJobId__c = event.AsyncApexJobId;
lcerror.Records__c = event.JobScope;
lcerror.StackTrace__c = event.StackTrace;
List_LeadConvertError.add(lcerror);