Posts

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 contac...

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:p...

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....

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>       ...

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...