Posts

Showing posts from January, 2016

Groups and Queues

Groups are set of Users. They contain individual users, other groups, the users in the particular role, the users in a particular role plus all of the users below that role in the hierarchy. There are two types of groups. 1. Public Group             |--> Only Administrator can create public groups, they can be used by everyone in the Organization. 2. Personal Group        |--> Each user can create groups for their personal use. Public Groups: Public Groups are set of users and they are used in a  Sharing Rule Giving Access to Folders Email alerts Public groups made up of any combination of  Users Roles Roles and Subordinates Public Groups When the Public Groups are made up of roles or roles and subordinates, when a User is added or removed from the role, the public group membership is updated. Queues: Queues allow groups of users to manage a shared workload more effectively. A queue is a location where records can be routed to a wait processing b

Reports

* Report types allow us to build a frame work in the report builder from which users can create and customize Reports. * A reoprt type define the set of records and fields available to a report based on the relationships between a primary object and its related objects. * Salesforce provides a large range of pre-defined standard report types. 1. Account&contact --> Contains information about accounts and contacts. 2. Opportunities 3. Customer support (Report types regarding cases and solutions) 4. Lead 5. Campaigns 6. Activities 7. Administrative Report types 8. Price Books, Products and Asset report types * Custom Report Types  In addition to the standard report types, we can also create custom report types. Custom report types extend the types of reports from which all users in organization can create or update custom reports.   

DashBoards

A DashBoard shows the data from source reports(Summary reports, Matrix reports) as visual components, which can be charts, gauges, tables, or visualforce pages. * Each dashboard can have up to 20 components * Administrators control access to dashboards by stroing them in folders with certain visibility settings. * Dashboards folders can be public, hidden or restricted to groups, roles. If we have access to a folder, we can view its dashboards.

Assign a task using Apex

public class TasKcreation {     public TasKcreation(){         String Userid=UserInfo.getUserId();         Contact c=new Contact(lastname='asasaa111');         insert c;         Task newTask = new Task(Description = 'Survey Transaction',                                         Priority = 'Normal',                                          Status = 'Inbound Email',                                          Subject = 'Other',                                          IsReminderSet = true,                                          ReminderDateTime = System.now()+1,                                          WhoId = c.id,                                         OwnerId=Userid);                              insert newTask;     } }

Share a case record using Apex and Trigger

Scenario:  Using Trigger share a record when record insert or update In trigger Call the Apex class  public class ShareRule4 {     public Static void afterInsert(List<Case> c){         List<CaseShare> cShare=new List<CaseShare>();         User u=[select Id from User where alias='aaxis'];         for(Case cs:c){             if(cs.Status=='New'){                 CaseShare cshr=new CaseShare();                 cshr.CaseAccessLevel='read';                 cshr.CaseId=cs.id;                 cshr.UserOrGroupId=u.id;                 cshr.RowCause='manual';                 cShare.add(cshr);             }         }         insert cShare;     } } trigger ShareRule4 on Case (after insert, after update) {     ShareRule4 s=new ShareRule4();     ShareRule4.afterInsert(trigger.new); }

Share a Account record Using Trigger

Scenario:   Whenever a new record is create or update, that record is shared to particular user trigger ShareRule2 on Account (after insert, after update) {     List<AccountShare> accShare=new List<AccountShare>();     user u=[select id from User where alias='aaxis'];     for(Account a:trigger.new){         if(a.Active__c=='yes'){         AccountShare accShr=new AccountShare();         accShr.AccountAccessLevel='read';         accShr.AccountId=a.id;         accShr.ContactAccessLevel='read';         accShr.CaseAccessLevel='read';         accShr.OpportunityAccessLevel='read';         accShr.RowCause='manual';         accShr.UserOrGroupId=u.id;         accShare.add(accShr);          }          }     insert accShare; } 

Share a record Using trigger class

Scenario:  Share the Opportunity record whose is closed won with a user trigger SharingRules on Opportunity (after update, after insert) {     list<OpportunityShare> opshare=new list<OpportunityShare>();     user u=[select id from user where alias='aaxis'];     //List<opportunity> lop=[select id from Opportunity where ]     for(opportunity op:trigger.new){         if(op.stagename=='Closed Won'){             OpportunityShare opshr=new OpportunityShare();             opshr.OpportunityId=op.id;             opshr.OpportunityAccessLevel= 'read';             opshr.UserOrGroupId=u.id;             opshr.RowCause='manual';             opshare.add(opshr);         }     }

Controller

Controller: A visualforce controller is a set of instructions that specify what happens when a user interacts with the components specified  in associated visualforce markup, such as when a user clicks a button or link. Controller also provide access to the data that should be displayed in a page, and can modify component behavior StandardController: A standardcontroller consist of the same functionality and logic that is used for a standard salesforce page. for eample , if you use the standar account controller, clicking a save button in a visualforce page results in the same behaviour as clicking save on a Standard Account detail page. <apex:page standardController="Account" > Custom Controller: A custom Controller is a class written in Apex that implements all of a page's logic. If we use a custom controller, we can define new navigation elements or behaviour, but we must also reimplement any functionality that was already provided in a standard

Create a group and group Member through Apex @future

public class FutureClass {     @future     public static void callme(ID myId){         GroupMember gmr=new GroupMember();         gmr.GroupId=myId;         gmr.UserOrGroupId=userInfo.getUserId();         insert gmr;     } } public class FutureExample {     public void show(){         Account ac=new Account(Name='FutureClassEx2');         insert ac;         Group newGroup=new Group();         newGroup.Name=ac.name;         newGroup.DoesIncludeBosses=false;         insert newGroup;         FutureClass.callme(newGroup.Id);     } }

Queueable Jobs

1. These are asynchronous jobs. 2. To implement the operation of queueable, we have to implement the interface of Queueable. 3. Any class that implements Queueable Interface has to define execute method. 4. The job that need to be implemented has to be designed with in execute method. 5. If you want to schedule the jobs we have to use System.enqueueJob. Ex:  public class QueueExample implements Queueable{     public void execute(QueueableContext context){        Account a=new Account(Name='AccName', Phone =' 12345');             insert a;     } } in Debug  System.enqueueJob(new QueueExample()); QueueExample queEx=new QueueExample(); system.enqueuejob(queEx);

Page Layouts

1. What is PageLayout? A: Pagelayout controls which fields will be displays in which order they will displayed ,which formate that field should be displayed. 2.How many pageLayouts can be assigned to a profile on a object? A: For every profile only one pagelayout is define. 3. What we can controll using pageLayout? A:Fields. 4. How to add Custom button on the PageLayout? A: Drag and drop 5. How to add Custom button relateed list in the pageLayout? A: 6. Find out what type of access is provided on the field when we have following combination             Field Level Security           Page Layout                    output?       Visable   Read     Required     Visable   Read   Required  1.     Ok         No            No                No       No        No 2.     Ok         No            No                 Ok       No      No 3.     Ok         No            NO                Ok       OK     No 4.     Ok          No           NO                OK      No       OK

Tabs

1. What is a tab? A: Tab is a user interface component to user creates to display custom object data. Tabs can help you in making the views which help user to see the information at a glance. Example: List of all contacts whose birthday is in this month, list of all opportunities which are in negotiation stage. There is a limitation on the number of tabs one can have in their organization, Maximum of 25 tabs are allowed in the enterprise edition. 2. How many types of tabs are there? A: There are four types of tabs. Custom Tabs Visual force Tabs Web Tabs Lightning Component Tabs 3. What is custom Object tab? A: Custom Object tabs (available only at an app level and not on subtab apps) display the data of your custom object in a user interface tab. Custom object tabs look and function just like standard tabs. 4. What is Visualforce page Tab? A: Visualforce tabs display data from a Visualforce page. Visualforce tabs look and function just like standard

Relations

1. What are the relations in the salesforce? A: A relationship is a bi-directional association between two objects. Relationships allows us to create  links between one object and another. The platform supports following relationship types Master-Detail Lookup Many-to-Many. User To User Esternal Lookup 2. WHAT IS MASTER DETAIL RELATION? A: Master Detail relationship is the Parent child relationship. In which Master represents Parent and detail  represents Child. If Parent is deleted then Child also gets deleted. Rollup summary fields can only be created  on Master records which will calculate the SUM, AVG, and MIN of the Child records. 3. HOW MANY MASTER DETAIL FIELDS CAN BE CREATED ON THE OBJECT? A: Up to 2 allowed to object. 4. IF WE DELETE THE PARENT RECORD WHAT WILL HAPPENS TO CHILD RECORDS? A: Deleting parent automatically deletes child. 5. WHO IS THE OWNER OF THE CHILD RECORDS IN MASTER DETAIL RELATION? A: Master 6. CAN CHILD RECORD BE A MASTER TO SOME OTH

Fields

1. How many types of fields are there in salesfroce? A: Fields are classified into three formats.      1. System Fields, 2. Standard Fields, 3. Custom Fields 2. What are system fields? A: System Fields: These are the fields which are created by the Salesforce and also updated by the salesforce whenever any operations occurs on the requirement. We can only perform read operation on this record. Id, IsDeleted, CreatedById, ModifiedBy, CreatedDate, ModifiedId, SystemModStamp, LastModifiedDate 3.What type of operations we vcan perform on the system fields? A:We can only perform read operation on the system fields. 4. What is the use of ID field? A:Id: Whenever new record is created in the salesforce, this will create 18 character Id for the record. This is a Unique Identifier. 5. What is the difference between 15 characters Id and 18 Character Id? A: In the 18 character Id first 3 Characters represents objects, last 4 characters represents record. We can also represent 18

Objects

1.What is Object? A Objects are database tables that allow you to store data specific to your organization in salesforce.com. You can use custom objects to extend salesforce.com functionality or to build new application functionality. Once you have created a custom object, you can create a custom tab, custom related lists, reports, and dashboards for users to interact with the custom object data. You can also access custom object data through the Force.com API. Navigation to create object in sales force:  Setup->Build->Create->Object-> Click on new object and create object according to your requirement. 2. What are the different types of objects in salesforce? A: Objects already created for you by Salesforce are called standard objects. Objects you create in your organization are called custom objects. Objects you create that map to data stored outside your organization are called external objects. 3.Can we delete the Standard Objects? A: Salesforc

Scenario

1. Create lookup field in contact object of contact, name as "Parent Contact". 2. Create picklist in contact name as Status with below values: a. Pending b. Running c. Completed 3. If someone change the status of contact then all parent contact should be updated with the same status. Example : Contact A Contact B Contact C Contact D Contact C is parent of Contact D, Contact B is parent of Contact C, Contact A is parent of Contact B Contact A (Status) = Running Contact B (Status) = Pending Contact C (Status) = Running And if we change the status of Contact D with "Completed" then all parent should be changed with "Completed" Status. public class StackEx {     public Static void updaterec(Set<String> nstr, String str){                   list<contact> ConListNew=new list<contact>();          list<contact> ContList =[select id,Parent_Contact__c,Status__c from contact  where id in: nstr];          for(contact con : Con

Interview Questons - 7

1. In Profile Settings, what is difference between "Modify All Data" and "Modify All"? A: Modify All Data: Create, Edit and Delete all organization Data, regardless of sharing settings. Modify All: Give all(Read, Create, Add, Delete) permission to selected Object. 2. If I want record level access then what should i use from Salesforce security model? A: Manual Sharing(Enabling "Sharing Button" at the profile level) 3. If i want Object level accesses then what should  i use from salesforce security model? A: Profile 4. What is madatory while creating User, Role or Profile? A: It's profile. 5. Who can run reports? A: User with permission "Run Report" and access to report folder can only run the report. 6. What is the difference between Printable view and Export view? A: Printable view: Formating, grouping and subtotals are persisted. Export  View: Formating, grouping and subtotals are lost. 7. Which permission is required t

SOQL Scenarios

Soql -1 Soql - 2 Soql - 3 Soql - 4 Soql - 5

SOQL Scenario- 5

Image
Aggregate functions public class SoqlQuery5 {     public list<Account> acc{set;get;}     public Integer count{set;get;}     public Decimal summ{set;get;}     Public decimal ttal{set;get;}     public Decimal mm{set;get;}     public Decimal mn{set;get;}     public SoqlQuery5(){         acc=[select Id, name, phone from account where name='s' limit 5];         count=[select count() from Account where name='s' ];         Aggregateresult result=[select sum(AnnualRevenue) amt, Avg(AnnualRevenue) total, Min(AnnualRevenue) minm, Max(AnnualRevenue) maxm from Account];         summ=(Decimal)result.get('amt');         ttal=(decimal)result.get('total');         mm=(Decimal)result.get('minm');         mn=(Decimal)result.get('maxm');     }   } <apex:page controller="SoqlQuery5">     <apex:form >     <apex:pageBlock >         <apex:pageBlockTable value="{!acc}" var="a">

SOQL Scenario -4

Image
Fetch the records Parent records from Child Object public class SoqlQuery4 {     public List<Contact> con{set;get;}     public SoqlQuery4(){         con=[select id, lastname, firstname, Account.name, Account.phone from contact];      } } <apex:page controller="SoqlQuery4" >     <apex:form >     <apex:pageBlock >         <apex:pageBlockTable value="{!con}" var="c">                 <apex:column headerValue="Con Name" value="{!c.lastname}" />                 <apex:column headerValue="Con Fname" value="{!c.firstname}" />                 <apex:column headerValue="Acc Name" value="{!c.Account.Name}" />                 <apex:column headerValue="Acc Phone" value="{!c.Account.phone}" />             </apex:pageBlockTable>         </apex:pageBlock>     </apex:form> </apex:page>

SOQL Scenario -3

Image
Parent to child Relationship fetch the Contact fields from Account // parent to child relationship public class SoqlQuery3 {     public List<Account> acc{set;get;}     public SoqlQuery3(){         acc=[select id, name, phone,(select id, lastname, firstname from contacts) from Account];     } } <apex:page controller="SoqlQuery3" >     <apex:form >     <apex:pageBlock >         <apex:pageBlockTable value="{!acc}" var="a">                 <apex:column headerValue="Acc Name" value="{!a.name}" />                 <apex:column headerValue="Acc Phone" value="{!a.phone}" />                 <apex:column headerValue="Con Details">                 <table>                         <apex:repeat value="{!a.contacts}" var="b">                     <tr>                         <td>{!b.lastname}</td><t

SOQL Scenario- 2

Image
Create pagination using Soql   public class SoqlQuery2 {     public list<Account> acc{set;get;}          public SoqlQuery2 ()     {         acc=new list<Account>();     }     integer count=0;     public void prev(){         if(count>10)             count=count-10;         else             count=0;     }     public void next(){         count=count+10;     }     public List<Account> getData(){         acc=[select id, name from account limit 10 offset: count];         return acc;     } } <apex:page controller="SoqlQuery2">     <apex:form >     <apex:pageBlock >         <apex:pageBlockSection >             <apex:pageBlockTable value="{!Data}" var="a">                     <apex:column headerValue="Name" value="{!a.name}" />                 </apex:pageBlockTable><br/>                 <apex:commandButton value="<<< prev&quo

SOQL Scenario-1

Image
Fetch the Name Fields from Account Object public class SoqlQuery1 {     public List<Account> acc{set;get;}     public SoqlQuery1(){         acc=[select id, name from Account];     } } <apex:page controller="SoqlQuery1" >     <apex:form >     <apex:pageBlock >         <apex:pageBlockSection >             <apex:pageBlockTable value="{!acc}" var="a">                     <apex:column headerValue="Name" value="{!a.name}" />                 </apex:pageBlockTable>             </apex:pageBlockSection>         </apex:pageBlock>     </apex:form> </apex:page>