Tuesday 24 May 2016

FORMULA AND VALIDATION RULE

create a Formula to calculate Age from Date of Birth


( TODAY() - DOB__C ) / 365.2425

create a validation rule Date of Birth Not equal to today


DOB__C = TODAY()

create a validation rule that Next visit (date type) should be greater than the created date +30 days after


Next_Visit__c  < (DATEVALUE( CreatedDate)  + 30)

Tuesday 17 May 2016

write a class and trigger to send an email after creating a patient record and once appointment has been created it should send an email.In this we have query Email Templates and we have to  fetch all the Email Id to send email.


CLASS:

public with sharing class Appointmenttriggerhandler{
public static void sendemailtoPatient(list<Appointment__c> appointments){
EmailTemplate et=[Select id from EmailTemplate where name='Appointment: New Customer Email'];
list<Messaging.SingleEmailMessage> emails = new list<Messaging.SingleEmailMessage>();
//To store patient Id
set<Id> setPatientId = new set<Id>();
if(appointments.size()> 0) {
for(Appointment__c iterator : appointments) {
if(iterator.Patient__c != null) {
setPatientId.add(iterator.Patient__c);
}
}
}
//fetch the patient records for whom an email needs to be sent
if(setPatientId.size()>0) {
list<Patient__c> Patients = [Select Id,Email__c from Patient__c where Id IN : setPatientId];
for(Patient__c pat : Patients){
if(pat.Email__c != null){
Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();
singleMail.toaddresses(pat.Email__c);
singleMail.setTemplateId(et.Id);
emails.add(singleMail);
}  
}
}
Messaging.sendEmail(emails);
}
}

TRIGGER:

trigger SendEmailToPatients on Appoinments (after insert) {
    if(Trigger.isAfter){
        if(Trigger.isInsert ){ 
            
            Appointmenttriggerhandler.sendEmail(trigger.new);
        }
    }
}

Sunday 15 May 2016

CREATION OF APP

To Create an APP there are THREE different ways;

STEP 1;
              Click Setup>>Force.com Home>> Getting started section>> Build App>>Add App . 
            
STEP 2; 
          Click Setup>>Force.com Home>>Scroll down toQuick links section>>Tools pane>>Click App Quick Start.
STEP 3; 
             Click Setup>> In Left side column>>Build section>>Click create>>Click Apps>>Click Quick start (or) New . 

BASICS OF SALESFORCE

SALESFORCE:

  • Cloud based software.
  • Customer Relationship Management.
  • The process about pre sales and post sales.
  • Salesforce is CRM only, with a place to store your customer data, processes to nurture and convert prospective customers, and ways to collaborate and engage.
  • Salesforce includes those things, but it also includes the platform, where customers and partners can use our suite of technologies to build amazing, connected apps.                           
OBJECT:  
  • object comprises a number of fields, which correspond to columns in a database. Data is stored in records of the object, which correspond to rows in a database.
Types of objects:
  • Standard Objects—These are objects included with Salesforce, by default, for example the objects used to store data in standard tabs such as accounts, contacts, or opportunities.
  • Custom Objects—These are new objects you create to store information unique to your organization. Custom objects extend the functionality that standard objects provide. 
RECORDS: 
  • Collection of field values.
CLICKS AND CODES:

  • Clicks----Declarative-----Points and clicks.
  • Codes----Programmatic--APEX,VISUAL FORCE PAGE.
DEPLOY: 
  •  Used to move data to production.
PLATFORM:
  • Using the platform, you can customize standard functionality and create custom pages, components, apps, and more, and you can do it all faster than you might expect.
SALESFORCE ARCHITECTURE:




METADATA:
  • Metadata literally means data about data.
EXAMPLE:When you work with Salesforce, you have configuration and customization specific to your business needs. This includes things like page layouts for your Accounts, Contacts, Leads, and any custom objects. It also includes processes, assignment rules, and sharing and security settings. On the programmatic side, it might also include things like Visualforce pages and Apex triggers. All of this represents what you’ve configured and customized in your org.

Your customer, prospect, and user data is in your org inside all of that structure. Now, imagine all of that data has just been exported. The structure is still there, but the data itself is gone. What you’d have left, that underlying structure, that is the metadata.
    ADVANTAGES OF MULTITENANT CLOUD:
    • All of our customers, from small businesses to enterprise companies, are on the same code-base and all get the benefits of the same features, functionality, and automatic upgrades 3 times a year.
    SANDBOXES:
    • Sandboxes are copies of your organization in a separate environment. They are used for development and testing
    Advantages of Force.com objects for app development:
    • Force.com platform provides a powerful database.
    • faster and easier to create applications.
    •  relational database, data is stored in tables.
    • Each table comprises a number of columns of a particular data type, such as text, number, or date.
    • Information is stored in rows of the table. 
    • Tables can be related to other tables, using primary and foreign keys. 
    • Apps manage information by creating, reading, updating, and deleting rows in a table.
    •  more powerful and versatile.
    •  Each object comprises a number of fields, which correspond to columns in a database. 
    • Data is stored in records of the object, which correspond to rows in a database.
    Custom Objects:
    • These are new objects you create to store information unique to your organization. Custom objects extend the functionality that standard objects provide. For example, if you’re building an app to track product inventory, you can create custom objects called Merchandise and Invoices.
    Identity Field:
    • Force.com automatically assigns an identity field (called ID) to every object, and manages the identity data in every record. This identity field usually comes in a 15-character case sensitive form.
    System Fields:
    • CreatedDate—the Date and time when the object was created
    • CreatedById—the ID of the User who created the object
    • LastModifiedById—the ID of the User who last modified the object
    • LastModifiedDate—the date and time when the object was last modified by a user
    • SystemModStamp—the date and time when the object was last modified by a user or process, such as a trigger.
    Custom Fields:
    • Auto Number—a system-generated read-only sequence number, analogous to the SQL identity type. These fields can be used to provide a unique ID that is independent of the internal object ID. These fields are not used in creating object relationships.
    • Checkbox—for representing Boolean data.
    • Date or Date/Time—for representing dates or date and time combinations.
    • Number—for representing real numbers, with optional decimal points.
    • Email, Phone and URL—format-validated email, phone and URL string representations.
    • Picklist and Multi-Select Picklists—represent values from a list.
    • Text and Text Areas—for representing text of various lengths.
    • Currency—a formatted number type, with optional multi-currency support.
    • Formula—a read-only field holding data generated from a formula expression.
    • Geolocation—allows you to identify locations by their latitude and longitude and calculate distances between locations.
    Relationship Fields:
    • A relationship field stores the ID of the parent record in a relationship, as well as optionally providing user interface representations in both the parent and child records.
    Lookup:
    • This creates a relationship that links one object to another object. The relationship field allows you to navigate from records in one object to the related records in another object (both visually, and programmatically). Lookup relationships can be used to create one-to-one and one-to-many relationships.
    Master-Detail:
    • This creates a special type of relationship between two objects (the child, or "detail") and another object (the parent, or "master"). Master-detail relationships can be used whenever there is a tight binding between two objects. For example, consider a blog and blog posts. If the blog is deleted, the blog posts should go too. They can also be used to create many-many relationships.
    GOVERNOR LIMITS:
                     Governor limits are runtime limits enforced by the Apex runtime engine. Because Apex runs in a shared, multitenant environment, the Apex runtime engine strictly enforces a number of limits to ensure that code does not monopolize shared resources.

    APEX CODE:
    Apex Code is the Force.com programming language used to write custom, robust business logic. Apex is compiled and executed on the Force.com multitenant infrastructure, which is a shared resource across all customers, partners, and developers