API
|
What can you use it for
|
REST API
|
Access the different objects in your org using standard REST protocols
|
SOAP API
|
Integrate your org’s data with other applications
|
Bulk API
|
Insert, delete and perform Async queries against large data sets
|
Metadata API
|
Build tools that manage your metadata model and make customizations in your org
|
Streaming API
|
Send/Receive secure notifications. These notifications can reflect data changes in your org or even custom events
|
Tooling API
|
Build custom development tools for different Salesforce Platform applications
|
Chatter REST API
|
Build a UI for Chatter, Files, Topics, Communities and more
|
Marketing Cloud API
|
Get comprehensive access to most email functionality with the SOAP API.
|
Mobile SDK
|
Integrate native or hybrid mobile apps directly with Salesforce
|
Wednesday, 6 December 2017
Salesforce API and Use
Thursday, 23 November 2017
Call Test Class
PageReference pageref = Page.ProcessSingleLeadInquiryIntegraton;
Test.setCurrentPage(pageRef);
Apexpages.currentPage().getParameters().put('id',integ.Id);
ApexPages.StandardController stdAct = new ApexPages.StandardController(integ);
LeadInquiryIntegrationExt leadinquiry = new LeadInquiryIntegrationExt(stdAct);
leadinquiry.proceedSingleLeadInquryIntegration();
leadinquiry.proceedAllNewLeadInquryIntegrations();
Test.setCurrentPage(pageRef);
Apexpages.currentPage().getParameters().put('id',integ.Id);
ApexPages.StandardController stdAct = new ApexPages.StandardController(integ);
LeadInquiryIntegrationExt leadinquiry = new LeadInquiryIntegrationExt(stdAct);
leadinquiry.proceedSingleLeadInquryIntegration();
leadinquiry.proceedAllNewLeadInquryIntegrations();
Monday, 20 November 2017
Account Billing City is update we need to update Contact Mailing City
trigger AccountTrigger on Account (after update)
{
// Set will avoid duplicates
// here adding the account id in set
Set<Id> set_accountId = new Set<Id>();
System.debug('Set the Account Values are : ' + set_accountId); // here getting values as null in list,set and map
//List is for bulk update
List<Contact> contactList = new List<Contact>();
System.debug('List the Account Values are : ' + contactList);
// Map is having the list of account id and the list of contacts
Map<Id,List<Contact>> mp_ListContact = new Map<Id,List<Contact>>();
System.debug('Map the Account Values are : ' + mp_ListContact);
// Inside for loop we are adding the account id in the Set. Set will avoid duplicates
for(Account acc : Trigger.new)
{
if(acc.billingcity!=Trigger.oldMap.get(acc.id).billingcity)
set_accountId.add(acc.id);
System.debug('Set the Account Values are : ' + set_accountId);
}
// In this for loop we are querying 'Contact' which is having the account.
// Here we need to check the governor limits . Important about query : accountId IN : set_accountId
for(Contact con : [Select Id,AccountId,mailingcity from Contact where accountId IN : set_accountId limit 50000])
{
// Adding the key and values
// Key is accountId
// Value is conlist
// conlist is having the accountid
//
if(mp_ListContact!=null && mp_ListContact.containsKey(con.AccountId))
{
List<Contact> conList = mp_ListContact.get(con.AccountId);
conList.add(con);
mp_ListContact.put(con.AccountId, conList);
}
else
mp_ListContact.put(con.AccountId, new List<Contact>{con});
}
for(Account acc : Trigger.new)
{
if(mp_ListContact!=null && mp_ListContact.containsKey(acc.id))
{
for(Contact con : mp_ListContact.get(acc.id))
{
// Write logic to update contact as sample below :
con.mailingcity= acc.billingcity;
con.FirstName = acc.Name;
contactList.add(con);
}
}
}
if(contactList!=null && contactList.size()>0){
update contactList;
}
}
{
// Set will avoid duplicates
// here adding the account id in set
Set<Id> set_accountId = new Set<Id>();
System.debug('Set the Account Values are : ' + set_accountId); // here getting values as null in list,set and map
//List is for bulk update
List<Contact> contactList = new List<Contact>();
System.debug('List the Account Values are : ' + contactList);
// Map is having the list of account id and the list of contacts
Map<Id,List<Contact>> mp_ListContact = new Map<Id,List<Contact>>();
System.debug('Map the Account Values are : ' + mp_ListContact);
// Inside for loop we are adding the account id in the Set. Set will avoid duplicates
for(Account acc : Trigger.new)
{
if(acc.billingcity!=Trigger.oldMap.get(acc.id).billingcity)
set_accountId.add(acc.id);
System.debug('Set the Account Values are : ' + set_accountId);
}
// In this for loop we are querying 'Contact' which is having the account.
// Here we need to check the governor limits . Important about query : accountId IN : set_accountId
for(Contact con : [Select Id,AccountId,mailingcity from Contact where accountId IN : set_accountId limit 50000])
{
// Adding the key and values
// Key is accountId
// Value is conlist
// conlist is having the accountid
//
if(mp_ListContact!=null && mp_ListContact.containsKey(con.AccountId))
{
List<Contact> conList = mp_ListContact.get(con.AccountId);
conList.add(con);
mp_ListContact.put(con.AccountId, conList);
}
else
mp_ListContact.put(con.AccountId, new List<Contact>{con});
}
for(Account acc : Trigger.new)
{
if(mp_ListContact!=null && mp_ListContact.containsKey(acc.id))
{
for(Contact con : mp_ListContact.get(acc.id))
{
// Write logic to update contact as sample below :
con.mailingcity= acc.billingcity;
con.FirstName = acc.Name;
contactList.add(con);
}
}
}
if(contactList!=null && contactList.size()>0){
update contactList;
}
}
Wednesday, 8 November 2017
When we use @isTest(seeAllData = true) ?
In salesforce, we have 2 types of object
Setup objects are like : (Where we can Create)
We cannot create a test data for non-setup objects. That time we need use in our test class as "@isTest(seeAllData = true)"
Setup objects are like : (Where we can Create)
Profile
Record Type,
Users
Non Setup Objetcs are like :
Contact
Lead
Account
Non-Setup objects are standard objects like Account or any custom object.
Setup objects are Group1, GroupMember, QueueSObject, User2, UserRole, UserTerritory, Territory, etc.
Setup objects are Group1, GroupMember, QueueSObject, User2, UserRole, UserTerritory, Territory, etc.
We cannot create a test data for non-setup objects. That time we need use in our test class as "@isTest(seeAllData = true)"
Monday, 6 November 2017
Count Number of Attachements in object
trigger countattachment on Attachment (after insert, after update, after delete, after undelete) {
Map<Id,List<Attachment>> parent = new Map<Id,List<Attachment>>();
set<id> attids = new set<id>();
if(Trigger.new<>null){
for(Attachment c:Trigger.new){
TestObject__c l;
if(c.ParentId != null)
attids.add(c.parentid);
}
}else if(Trigger.old != null){
for(Attachment c:Trigger.old){
if(c.ParentId<>null)
attids.add(Trigger.oldMap.get(c.id).parentid);
}
}
if(attids.size()>0){
try{
List<Attachment> a = new List<Attachment>();
Map<id,TestObject__c> testmap = new Map<id,TestObject__c>([select id,CountAttachment__c from TestObject__c where id IN: attids]);
a = [select id,parentid from Attachment where parentid IN:attids];
for(Attachment at: a){
List<Attachment> llist = new List<Attachment>();
if(parent.get(at.parentid) == null){
llist = new List<Attachment>();
llist.add(at);
parent.put(at.parentid,llist);
}else if(parent.get(at.parentid) != null){
llist = new List<Attachment>();
llist = parent.get(at.parentid);
llist.add(at);
parent.put(at.parentid,llist);
}
}
for(Id i: attids){
if(testmap.get(i) != null && parent.get(i) != null){
testmap.get(i).CountAttachment__c = parent.get(i).size();
}else if(testmap.get(i) != null && parent.get(i) == null){
testmap.get(i).CountAttachment__c = 0;
}
}
update testmap.values();
System.Debug(testmap.values());
}catch(Exception e){}
}
}
Map<Id,List<Attachment>> parent = new Map<Id,List<Attachment>>();
set<id> attids = new set<id>();
if(Trigger.new<>null){
for(Attachment c:Trigger.new){
TestObject__c l;
if(c.ParentId != null)
attids.add(c.parentid);
}
}else if(Trigger.old != null){
for(Attachment c:Trigger.old){
if(c.ParentId<>null)
attids.add(Trigger.oldMap.get(c.id).parentid);
}
}
if(attids.size()>0){
try{
List<Attachment> a = new List<Attachment>();
Map<id,TestObject__c> testmap = new Map<id,TestObject__c>([select id,CountAttachment__c from TestObject__c where id IN: attids]);
a = [select id,parentid from Attachment where parentid IN:attids];
for(Attachment at: a){
List<Attachment> llist = new List<Attachment>();
if(parent.get(at.parentid) == null){
llist = new List<Attachment>();
llist.add(at);
parent.put(at.parentid,llist);
}else if(parent.get(at.parentid) != null){
llist = new List<Attachment>();
llist = parent.get(at.parentid);
llist.add(at);
parent.put(at.parentid,llist);
}
}
for(Id i: attids){
if(testmap.get(i) != null && parent.get(i) != null){
testmap.get(i).CountAttachment__c = parent.get(i).size();
}else if(testmap.get(i) != null && parent.get(i) == null){
testmap.get(i).CountAttachment__c = 0;
}
}
update testmap.values();
System.Debug(testmap.values());
}catch(Exception e){}
}
}
System Mode vs User Mode in salesforce.
User Mode - Profile level permissions, field-level security, and sharing rules of the current user are enforced.System Mode - Object permissions, field-level security, sharing rules aren't applied for the current user.
This is the consolidated list of execution and mode of execution:
- Trigger - System
- Validation Rule - System
- Auto Response Rule - System
- Assignment Rule - System
- Workflow Rule - System
- Escalation Rule - System
- All Types of calculation behind formula, Rollup Summary - System
- Process Builder - System
- Visual Workflow or flow - User
- if flow is called from Process Builder - System
- if flow is called from Workflow - System
- if flow is called from Apex - (depends on with or w/o sharing of apex class)
- if flow is called from Custom Button - System
- if flow is embed in Visualforce - Depends on VFP context
- if flow is called from REST API - System
- Approval Process - System
- Publisher Action - System
- InvocableMethod
- if this is called from flow - User
- if this is called from Process Builder (does it depends on with or without sharing is specified on that Class) - System
- if this is called from REST API - (depends on with or w/o sharing of the class)
- Custom Button - System
- Test method with System.runAs() - User
- Test method without System.runAs() - System
- Visualforce Page (StandardController) - User
- Visualforce Page (StandardController with extension) - System
- Visualforce Page (Custom Controller)
- depends on with or without sharing of the controller
- Visualforce Component - depends on Visualforce page where it is used
- Macros - System
- Annonymous Apex - User
- Chatter in Apex - User
- Email Service - User
- Batch Class - User
- All types of Jobs - System
- Apex Webservices (SOAP API and REST API) - System (Consequently, the current user's credentials are not used, and any user who has access to these methods can use their full power, regardless of permissions, field-level security, or sharing rules.)
Subscribe to:
Posts (Atom)
Batch Apex
1. What are transaction limits in apex? Total number of SOQL queries issued1 - 100 Total number of records retrieved by SOQL queries - 50...
-
Trigger trigger LiveChatTranscriptEventTrigger on LiveChatTranscriptEvent (before delete) { /** * trigger runs * ...
-
27. What is difference between WhoId and WhatId in the Data Model of Task ? Ans : WhoID refers to people things. So that would be typ...
-
Links https://www.shellblack.com/administration/owds/ https://www.simplilearn.com/top-salesforce-interview-questions-and-answers-artic...