Salesforce Post Refresh Considerations Apex Scheduler Syntax and Send a Email Code


246. Write a syntax and structure of scheduler class?
Sample class

global class ScheduleDemo implements Schedulable{
    global void execute(SchedulableContext sc){
        BatchClass b = new BatchClass();
        database.executeBatch(b);
}
}

247. Write a apex code to send a email?

Sample code snippet to send an email using apex code

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[]{‘talk2srikrishna@gmail.com’};
mail.setToAddress(toAddresses);
mail.setSubject(‘Sample Mail Subject’);
mail.setPlainTextBody(‘Hello World!’);
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});


248. What are the aggregate functions supported by salesforce SOQL?
Following aggregate functions are supported by salesforce SOQL
1.     SUM()
2.     MIN()
3.     MAX()
4.     COUNT()
5.     AVG()
6.     COUNT_DISTINCT()

249. Write a sample aggregate query or explain how to write a aggregate queries?
The return types of Aggregate functions are always an array of AggregateResult.

Sample Code

AggregateResult[] ar = [select AVG(Amount) aver from Opportunity];
Object avgAmt = ar[0].get(‘aver’);

250. Write a code to find the average Amount for all your opportunities by campaign?

AggregateResult[] arList = [select CampaignId, AVG(amount) from Opportunity group by CampaignId];
for(AggregateResult ar : arList){
    System.debug(‘CampaignId ’ + ar.get(‘CampaignId’));
    System.debug(‘Average Amount’ + ar.get(‘expr0’));

}

251. What are email services in salesforce and explain how we can use them in code?
Email services are automated processes that use apex class to process the contents, headers and attachment of an inbound email.

Sample code

Use Case: create a contact record if the inbound email subject is Create Contact and body contains contact name

global CreateContactFromEmail implements Messaging.InboundEmailHandler{
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelop envelop){
    Messaging.InboundEmailResult res = new Messaging.InboundEmailResult();
    String strToCompare = ‘Create Contact’;
    If(email.subject.equalsIgnoreCase(strToCompare)){
        Contact c = new Contact();
        c.LastName = email.plainTextBody();
        insert c;
       
        //save text attachments

for(Messaging.InboundEmail.TextAttachment att : email.textAttachments){
    Attachment a = new Attachment();
    a.Name = att.fileName;
    a.Body = att.Blob.valueOf(att.Body);
    a.ParentId = c.Id;
    insert attachment;
}
       
//save binary attachments

for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
            Attachment attachment = new Attachment();
            attachment.Name = bAttachment.fileName;
            attachment.Body = bAttachment.body;
            attachment.ParentId = c.Id;
            insert attachment;
}
}
res.Success = true;
return res;
}
}

252. What is the relationship between Contact and Account objects in salesforce?
In Salesforce, Contacts is having a look up relationship with Accounts i.e., Simple relationship

253. What are different Organization Wide Defaults? Explain each of them?
Below are the different OWD values

Private
    If the OWD for an object is set to private, then only the owner, and users above that role in role hierarchy, can view, edit and report on those records

Public Read Only
    If the OWD for an object is set to Public Read Only, then all users can view and report on records but they cannot edit them. Only the record owner and the users above that role in the role hierarchy can edit the records

Public Read/Write
If the OWD for an object is set to Public Read/Write, then all users can view, edit and report on all records. But only owner of the record can delete the records.

Public Read/Write/Trfer
This is available only for Case and Lead objects
If the OWD for an object is set to Public Read/Write/Trfer then, all users can view, edit, trfer and report on all the records but only owner of the record can delete the records

Public Full Access
This is available only for Campaign object.
If the OWD for Campaigns are set Public Full Access then, all users can view, edit, delete and report on all records.

No Access, View Only or Use
This is available only for Price Book object.

If the OWD for Price Book is set Use then, all users can access the Price Book information and as well as using the Price Book configuration for Opportunities with Products.


If the OWD for Price Book is set View Only then, all users can access the Price Book information but not to use that Price Book detail in Opportunities with Products

If the OWD for Price Book is set No Access then, it restricts users from accessing information for Price Book and Prices.

Controlled By Parent
If the OWD for any object is set as Controlled By Parent, then user can perform an action on the record based on whether they can do the same on the parent record associated with it

254. Is it mandatory to select User License while creating permission sets? If not, what is the significance of selecting a User License?
It is not mandatory to select a User License while creating a permission sets.
If users with one type of license will use this permission set, then choose the same license that’s associate with them.
If you are planning to assign this permission set to multiple users with different licenses then, choose none.

255. Can we create a new profile without cloning an existing profiles?

No, we have to clone any one of the existing profiles to create a new profile


256. Please explain the use of Grant Access Using Hierarchies?

In Sharing settings, OWD settings, we have a check box Grant Access Using Hierarchies (for both standard and custom objects). If this check box is checked then it will give automatic access to the user’s data to other users in higher role of salesforce CRM Role Hierarchy.
If this check box is not checked then, only record owner and users granted access by OWD can gain the access.

257. What is the batch size limit (increment size for batch) in Data Loader?

Data Loader batch size limit is maximum of 200 per increment and if we selected Use Bulk API then maximum value is 10000

258. What is the difference between Export and Export All in the context of Data Loader?


Export enables user to export all the records for a particular object excluding the records in the recycle bin or soft deleted records.
Export All enables user to export all the records for a particular object including the records in the recycle bin or soft deleted records.

259. What are the post refresh considerations?


1.     New Organization ID is assigned to the refreshed sandbox every time it is refreshed. Hence we need to replace the hard coded organization id in our sandbox post refresh with newly created organization id.
2.     To ensure the uniqueness, in all user records, user name will be appended by sandbox name, if the resulting user name is not unique then, second round of modification is performed to prepend the user name with alpa numeric string to make sure the resulting username is unique.
3.     The copy process does not copy contact data to developer and configuration sandboxes. Therefore, customer portal users are not copied. These customer portal users need to be created manually on need basis.
4.     User email addresses are modified in sandbox to avoid sending any mail from sandbox such as notifications triggered by workflows and escalations rules.
5.     Newly created sandboxes have the default email deliverability setting System email only. We need to change this to All Email.
6.     If Server URL is hardcoded in the code, then we need to replace it with the newly created URL

260. What is the storage limit of Full Copy, Configuration Only and Developer sandboxes?
Full Copy Sandbox has the same storage limit as your production organization
Configuration Only sandbox has the storage limit of 500MB
Developer Sandbox has the storage limit of 10MB

261. What is the interval of refreshing of Full Copy, Configuration Only and Developer sandboxes?

Full Copy Sandbox can be refreshed once in 29 days
Configuration Sandbox can be refreshed once per day
Developer Sandbox can be refreshed once per day

262. What are the default sharing settings?

Default sharing settings are as follows
1.     Controlled By Parent
2.     Private
3.     Public Read Only
4.     Public ReadWrite
5.     Public Read/Write/Trfer (Only for Case and Lead objects)
6.     Public Full Access (Only for Campaign object)
7.     Grant Access Using Hierarchies

263. How many roles we can create for an organization?

We can create up to 500 roles for an organization

264. How many permission sets we can create for an organization?

We can create up to 1000 permission sets for an organization

265. How many types of custom tabs are available in salesforce?

There are 3 types of custom tabs are available in salesforce
1.     Custom Object Tabs
2.     Visualforce Tabs
3.     Web Tabs