Posts

Showing posts from 2016

Insert CSV file into a object

<apex:page standardController="Inserting_Record__c" extensions="HWCSVFileRead" showHeader="false"  sidebar="false">     <apex:form >     <apex:pageBlock >         <apex:pageBlockSection >                 <apex:outputText >Select The File</apex:outputText>             <apex:inputFile value="{!body}" />             </apex:pageBlockSection>                       <apex:commandButton value="Save" action="{!importingCSVFile}" />         </apex:pageBlock>     </apex:form> </apex:page> public class HWCSVFileRead {     public string stringVal {set;get;}     public string[] liststring {set;get;}     public Blob body {set;get;}     public list<medical__c> medical {set;get;}     public list<medical__c> medical1 {set;get;}     public list<medical__c> medical2 {set;get;}

Count Of Contacts

trigger CountOfContact on Contact (after insert, after update, after delete) {          list<account> acc=[select id, number__c, (select id, accountid from contacts) from Account];     list<account> act=new list<account>();     for(account aa:acc){         aa.number__c = aa.contacts.size();         act.add(aa);     }     update act; }

OWD - Sharing Settings

Owd: Organization wide default This is specify witch records in the table can be viewed by the user and what type of operation user can perform on the records. Private: If you define OWD as private only owner of the records can perform R|W|D operations on the records Public Read: If you define OWD as Public Read all the Users in the Organization can perform read operation on all the records and they can perform read and write and delete operations on the records for which they are owners. Public Read|Write: If you define OWD as Public Read|Write all the users in the organization can perform Read and Write Operations on all the records and owners can perform Read|Write|Delete operations on their own records. Public Read|Write|Transfer: This OWD can be defined only in Case and Lead object. If you define Public Read|Write|Transfer on case object or Lead Object all the users can perform operations of  Read|Write|Transfer an all the records. Public Full Access :

Workflows

Automated Action: Many of the tasks you normally assign, the emails you regularly send, and other record updates are part of your organization's standard processes. Instead of doing this work manually, you can configure workflow to do it automatically. What is Workflow? Workflow automates the following types of actions based on your organization's processes: Tasks—Assign a new task to a user, role, or record owner. Email Alerts—Send an email to one or more recipients you specify. Field Updates—Update the value of a field on a record. Outbound Messages—Send a secure, configurable API message (in XML format) to a designated listener. For example, workflow can: Assign follow-up tasks to a support rep one week after a case is updated. Send sales management an email alert when a sales rep qualifies a large deal. Change the Owner field on a contract three days before it expires. Trigger an outbound API message to an external HR system to initiate the reimburse

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