Skip to content

Instantly share code, notes, and snippets.

View vetriselvanSF's full-sized avatar

vetriselvanSF

View GitHub Profile
Sample Package.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<!-- Custom Object Tab, Web Tab and Visualforce tab -->
<types>
<members>Employee__c</members>
<name>CustomTab</name>
</types>
<types>
public class CaseTriggerHandler{
@future(callout=true)
public static void checkSentiments( String caseId ){
EinsteinAPI ea = new EinsteinAPI();
Double positive;
Double negative;
Double neutral;
String result;
SentimentAnalysisResponse sar = new SentimentAnalysisResponse();
@vetriselvanSF
vetriselvanSF / SampleDatatable.cls
Last active February 20, 2018 15:50
Sample Datatable.js in visualforce page
public class SampleDatatable{
/**
* On basis of field set, Create Dynamic SOQL
*/
public List<Opportunity> getOpportunity() {
List<Schema.FieldSetMember> fsm = SObjectType.Opportunity.FieldSets.Opportunity_Field_Set.getFields();
String query = 'SELECT ';
for(Schema.FieldSetMember f : fsm ) {
query += f.getFieldPath() + ', ';
@vetriselvanSF
vetriselvanSF / minilayout
Created November 29, 2017 12:36
minilayout
<a href="/{!opp.id}" id="lookup{!opp.id}popup" onblur="LookupHoverDetail.getHover('lookup{!opp.id}popup').hide();"
onfocus="LookupHoverDetail.getHover('lookup{!opp.id}popup', '/{!opp.id}/m?retURL=/{!opp.id}&isAjaxRequest=1').show();"
onmouseout="LookupHoverDetail.getHover('lookup{!opp.id}popup').hide();"
onmouseover="LookupHoverDetail.getHover('lookup{!opp.id}popup', '/{!opp.id}/m?retURL=/{!opp.id}&isAjaxRequest=1').show();">
{!opp.Name}
</a>
public class ProbabilityController{
public Opportunity thisOpp { get; set; }
public ProbabilityController(){
thisOpp = new Opportunity();
}
// Method the the Probability
// Called when the Stage Picklist is changed
public PageReference getProbability() {
public class GenerateJSON{
// Method to generate the JSONBody for the List of accounts
public void GenerateJSONBody(List<Account> accList){
// Instantiate the JSONGenerator class to access the method
JSONGenerator gen = JSON.createGenerator(true);
gen.writeStartObject(); // Writes the starting marker of JSON object - {
gen.writeFieldName('request'); // Writes the fieldName
gen.writeStartObject(); // Writes the starting marker of JSON object - {
gen.writeFieldName('customer');
public class ShortenURL{
// Wrapper class for the Shorten URL JSON Response
public class ShortenURLWrapper {
public String kind;
public String id;
public String longUrl;
}
// Method to build the JSON Request and do callout
@vetriselvanSF
vetriselvanSF / OpportunityRelatedList.vfc
Created October 29, 2017 14:46
Fieldsets - APEX & Visualforce
<apex:page standardController="Account" extensions="OpportunityRelatedListClass" sidebar="false" showHeader="false">
<apex:pageblock id="pb">
<apex:pageBlockSection collapsible="false" columns="1">
<apex:pageBlockTable value="{!Opportunities}" var="opp" styleClass="dataTable">
<apex:column title="Edit">
<apex:outputLink style="color:#015ba7" value="{!URLFOR($Action.Opportunity.Edit, opp.Id, ['retURL'='/%2F'+ opp.AccountId])}" target="_top">Edit</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">Opportunity Name</apex:facet>
<apex:outputLink value="/{!opp.Id}" target="_top">{!opp.Name}</apex:outputLink>