Skip to content

Instantly share code, notes, and snippets.

Dhanik Lal Sahni dhaniksahni

View GitHub Profile
dhaniksahni / childModule.html
Created Jul 9, 2020
childModule for errorCallback
View childModule.html
dhaniksahni / parentModule.html
Created Jul 9, 2020
parentModule for errorCallback
View parentModule.html
<template if:true={hasError}>
<div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_error" role="alert">
<span class="slds-assistive-text">error</span>
<h2>Application Error:{error.message}
View EinsteinOCRReponse.cls
public class EinsteinOCRReponse {
public list<Probability> probabilities{get;set;}
public String objects{get;set;}
public String task{get;set;}
public class Probability{
public boundingBox boundingBox{get;set;}
public String label{get;set;}
public Decimal probability{get;set;}
public class BoundingBox{
dhaniksahni / EinsteinOCR.cls
Last active Jul 8, 2020
EinsteinOCR API Call from Apex
View EinsteinOCR.cls
public class EinsteinOCR {
public static String VISION_API = '';
public static string extractText(String imageUrl, String token, String model) {
HttpRequest req = new HttpRequest();
req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"');
req.setHeader('Authorization', 'Bearer '+ token); //replace token with your access token
dhaniksahni / EinsteinController.cls
Created Jun 24, 2020
API Token Generator for Einstein AI Services
View EinsteinController.cls
public class EinsteinController {
public String getAccessToken() {
ContentVersion base64Content = [SELECT Title, VersionData FROM ContentVersion where Title='einstein_platform' OR Title='predictive_services' ORDER BY Title LIMIT 1];
String keyContents = base64Content.VersionData.tostring();
keyContents = keyContents.replace('-----BEGIN RSA PRIVATE KEY-----', '');
keyContents = keyContents.replace('-----END RSA PRIVATE KEY-----', '');
keyContents = keyContents.replace('\n', '');
JWT jwt = new JWT('RS256');
jwt.pkcs8 = keyContents;
dhaniksahni / CaseService.apxc
Last active Jun 16, 2020
License Plate Number Reader in Salesforce
View CaseService.apxc
public class CaseService {
public static void UpdatePlateNumber(string record,string plate)
Case caseRecord=[Select Id, Plate_Number__c from Case where id=:record];
update caseRecord;
dhaniksahni / code.ts
Created Jun 7, 2020
Salesforce Codex Plugin
View code.ts
import * as fs from 'fs';
import * as fse from 'fs-extra';
import * as path from 'path';
export class Code
updateContent=function(content, values) {
const splitValues = values.split('=');
const varName = splitValues[0];
dhaniksahni / trigger.cls
Created Jun 7, 2020
Salesforce Codex Plugin
View trigger.cls
public trigger {{objectName}}Trigger on {{entityName}}( after insert, after update, before insert, before update)
{{objectName}}TriggerHandler handler = new {{objectName}}TriggerHandler(Trigger.isExecuting, Trigger.size);
if( Trigger.isInsert )
dhaniksahni / apex.cs
Created Jun 7, 2020
salesforcecodex plugin
View apex.cs
public with sharing class {{objectName}} {
//save record
public void save{{objectName}}(string name) {
{{objectName}}Selector objRecord=new {{objectName}}Selector();
{{objectName}} record=objRecord.getByName(name);
dhaniksahni / metadataInfo.html
Created May 31, 2020
Metadata Information using Lightning Tree Node
View metadataInfo.html
<lightning-card title="Used Custom Metadata" icon-name="custom:custom10">
<div class="slds-grid">
<div class="slds-size--1-of-1">
<lightning-button label="Export in CSV" onclick={handleFileDownload}></lightning-button>
You can’t perform that action at this time.