To create and test a schedulable class, let’s take a look at how to schedule the class using the user interface.
- Create an apex which implemented the schedulable.
global class TestScheduleService implements Schedulable
global void execute(SchedulableContext SC)
- Your Name -> Setup
- App Setup -> Develop -> Apex Classes
- Schedule Apex button at the top -> Click Schedule Apex button
- Here you can manually schedule an apex class which implemented the schedulable interface.
To create a new VisualForce page go to “Your Name” > Setup > Develop > Pages and click the New button.
- Your Name” > Setup
- Develop > Pages
- New Page Button
You will now see the VisualForce page creation wizard. The very first thing you will want to do is give your new VisualForce page a Label. A label is a more esthetic name of what your page name will actually be.
Once you’ve typed your page label press the Tab key to set your cursor to the Name field. You will notice that the Name automatically took the value of “Test Page” from Label. SalesForce won’t allow you to have spaces in the name so replace your space with an Underscore character as shown below.
SalesForce will automatically give you some default VisualForce markup to work with as shown below.
<!-- Begin Default Content REMOVE THIS -->
This is your new Page
<!-- End Default Content REMOVE THIS -->
- And now save your page.
- For preview click on preview button.
Master-Detail Relationship (1:N) :
A parent-child relationship in which the master object controls certain behaviors of the detail object:
- When a record of the master object is deleted, its related detail records are also deleted.
- The Owner field on the detail object is not available and is automatically set to the owner of its associated master record. Custom objects on the detail side of a master-detail relationship cannot have sharing rules, manual sharing, or queues, as these require the Owner field.
- The detail record inherits the sharing and security settings of its master record.
- The master-detail relationship field is required on the page layout of the detail record.
- By default, records can’t be re-parented in master-detail relationships. Administrators can, however, allow child records in master-detail relationships on custom objects to be re-parented to different parent records by selecting the Allow re-parenting option in the master-detail relationship definition.
We can define master-detail relationships between custom objects or between a custom object and a standard object. However, the standard object cannot be on the detail side of a relationship with a custom object. In addition, we cannot create a master-detail relationship in which the User or Lead objects are the master.
When we define a master-detail relationship, the custom object on which you are working is the detail side. Its data can appear as a custom related list on page layouts for the other object.
Many-To-Many Relationship (N:N):
We can use master-detail relationships to model many-to-many relationships between any two objects. A many-to-many relationship allows each record of one object to be linked to multiple records from another object and vice versa. For example, We may have a custom object called “Bug” that relates to the standard case object such that a bug could be related to multiple cases and a case could also be related to multiple bugs. To create a many-to-many relationship, simply create a custom junction object with two master-detail relationship fields, each linking to the objects you want to relate.
Note: Custom objects with two master-detail relationships are supported in API version 11 and later.
Lookup Relationship (1:N):
This type of relationship links two objects together, but has no effect on deletion or security. Unlike master-detail fields, lookup fields are not automatically required. When we define a lookup relationship, data from one object can appear as a custom related list on page layouts for the other object. See the Salesforce online help for details.
You might wanted to bring your records like Select id from Account where Column1 = Column2, which is not possible in Salesforce.
For this you have to create a formula field as Text and then populate this field as TRUE if the column1 = column2 else populate the value as FALSE.
Finally you can write a query as:
select id from Account where formulafield = 'TRUE'