Skip to content

Instantly share code, notes, and snippets.

@swapnilshrikhande
swapnilshrikhande / getDependentOptions.js
Created June 14, 2018 14:47
Salesforce : Get picklist dependent options
var getDependentOptions = function(objName, ctrlFieldName, depFieldName) {
try{
// Isolate the Describe info for the relevant fields
sforce.connection.sessionId = "{!$Api.Session_ID}";
var objDesc = sforce.connection.describeSObject(objName);
var ctrlFieldDesc, depFieldDesc;
var found = 0;
for (var i=0; i<objDesc.fields.length; i++) {
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script src="main.js" charset="utf-8"></script>
</head>
<body>
</body>
@swapnilshrikhande
swapnilshrikhande / Rest
Last active May 22, 2018 09:34
Rest invoke utility for salesforce
public class Rest {
public Enum HttpMethod { GET, POST, PUT, PATCH }
public HttpRequest request {set;get;}
public HttpResponse response {set;get;}
public Integer timeout {set;get;}
// Method to create HTTP request with parameters
public Rest createHttpRequest(String endpoint,
HttpMethod method,
var getValue = function(record,field) {
if( field.value )
return field.value;
var fieldApiName = field.apiName;
return getValueByApiName(record,fieldApiName);
};
function getValueByApiName(record,fieldApiName){
@swapnilshrikhande
swapnilshrikhande / Modal
Last active April 5, 2018 13:59
Lightning Modal Component
<apex:component >
<apex:attribute name="message" description="message" type="String" required="false"/>
<apex:attribute name="title" description="Header title" type="String" required="true"/>
<apex:attribute name="primary_button_label" description="Primary button label" type="String" required="true"/>
<apex:attribute name="secondary_button_label" description="Primary button label" type="String" required="false"/>
@swapnilshrikhande
swapnilshrikhande / clipboard.js
Last active December 15, 2017 13:25
Copy To Clipboard Button For Standard Layout
/*!
* clipboard.js v1.7.1
* https://zenorocha.github.io/clipboard.js
*
* Licensed MIT © Zeno Rocha
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var DOCUMENT_NODE_TYPE = 9;
/**
@swapnilshrikhande
swapnilshrikhande / processBatchChain
Created December 14, 2017 15:10
Batch without hitting governor limits
private void processBatchChain(Boolean isCurrentBatch)
{
Integer jobs = [Select count() From AsyncApexJob Where JobType = 'BatchApex' and ( Status = 'Queued' or Status = 'Processing' or Status = 'Preparing' )];
if(jobs != null && jobs > 4 )
{
scheduleBatch(isCurrentBatch);
}
else
{
runBatch(isCurrentBatch);
@swapnilshrikhande
swapnilshrikhande / genericTriggerHTMLEvent
Created December 5, 2017 09:48
Good generic trigger
//credits : https://stackoverflow.com/questions/5569927/change-google-translate-dropdown-programatically
function triggerHtmlEvent(element, eventName) {
var event;
if(document.createEvent) {
event = document.createEvent('HTMLEvents');
event.initEvent(eventName, true, true);
element.dispatchEvent(event);
} else {
event = document.createEventObject();
@swapnilshrikhande
swapnilshrikhande / arabic_transliteration.php
Created November 23, 2017 16:15 — forked from zekizeki/arabic_transliteration.php
A php script to provide simple english->arabic arabic->english transliteration
<?php
/*
* Created on 05-Jul-2006
* [email protected]
* Translator class calls external machine translation component
*/
class Phonetics
{
<article class="article-page">
<div class="page-content">
<div class="wrap-content">
<header class="header-page">
<h1 class="page-title">Hi Friend...</h1>
</header>
</div>
</div>
</article>