Friday, 12 August 2011
Tuesday, 9 August 2011
Monday, 1 August 2011
Apex Scheduler
Apex Scheduler
To invoke Apex classes to run at specific times we use Apex Scheduler
Steps to implement Schedulable Apex
1. Implement Schedulable Interface for the class
E.g.: global class scheduledMerge implements Schedulable{
// Schedulable Class
//Schedulable Method Mandatory for each Interface
global void execute(SchedulableContext SC) {
//Class which has to be scheduled
mergeNumbers M = new mergeNumbers();
}
}
The Schedulable interface contains one method that must be implemented, execute.
global void execute(SchedulableContext sc){}
SchedulableContext object is used to keep track of the scheduled job once it's scheduled.
The SchedulableContext method getTriggerId returns the Id of the CronTrigger object associated with this scheduled job as a string. Use this method to track the progress of the scheduled job.
2. To Implement the above class in step 1 we need to use System.Schedule Method
The following example uses the System.Schedule method to implement the above class.
scheduledMerge m = new scheduledMerge();// Creating object of the Schedulable
Class
String sch = '20 30 8 10 2 ?';// Format of when and at what time the process is
scheduled
system.schedule('Merge Job', sch, m); // Implementing the Schedule Process
The System.Schedule method takes three arguments: a name for the job, an expression used to represent the time and date the job is scheduled to run, and the name of the class. This expression has the following syntax:
Seconds Minutes Hours Day_of_month Month Day_of_week optional_year
The following are the valid values for the above expression:
Name Values Special Characters
Seconds 0–59 None
Minutes 0–59 None
Hours 0–23 , - * /
Day_of_month 1–31 ,- * ? / L W
Month 1–12 or the following: , - * /
JAN – DEC Any Month
Day_of_week 1–7 or the following: , - * ? / L #
SUN-SAT Any Day
optional_year null or 1970–2099 , - * /
The special characters are defined as follows:
• , —Delimits values. For example, use JAN, MAR, APR to specify more than one month.
• - —Specifies a range. For example, use JAN-MAR to specify more than one month.
• * —Specifies all values. For example, if Month is specified as *, the job is scheduled for every
month.
• ? —Specifies no specific value. This is only available for Day_of_month and Day_of_week, and
is generally used when specifying a value for one and not the other.
• / —Specifies increments. The number before the slash specifies when the intervals should
begin, and the number after the slash is the interval amount. For example, if you specify
1/5 for Day_of_month, the Apex class runs every fifth day of the month, starting on the
first of the month.
• L —Specifies the end of a range (last). This is only available for Day_of_month and
Day_of_week.When used withDay of month, L always means the last day of the month,
such as January 31, February 28 for leap years, and so on.When used with Day_of_week
by itself, it always means 7 or SAT.When used with a Day_of_week value, it means the
last of that type of day in the month. For example, if you specify 2L, you are specifying
the last Monday of the month. Do not use a range of values with L as the results may be
unexpected.
• W —Specifies the nearest weekday (Monday-Friday) of the given day. This is only available for
Day_of_month. For example, if you specify 20W, and the 20th is a Saturday, the class
runs on the 19th. If you specify 1W, and the first is aSaturday, the class does not run in
the previous month, but on the third, which is the following Monday.
• # —Specifies the nth day of the month, in the format weekday#day_of_month. This is only
available for Day_of_week. The number before the # specifies weekday (SUN-SAT). The
number after the # specifies the day of the month. Forexample, specifying 2#2 means the
class runs on the second Monday of every month.
The following are some examples of how to use the expression.
Expression Description
0 0 13 * * ? Class runs every day at 1 P.M.
0 0 22 ? * 6L Class runs the last Friday of every month at 10 P.M.
0 0 10 ? * MON-FRI Class runs Monday through Friday at 10 A.M.
0 0 20 * * ? 2010 Class runs every day at 8 P.M. during the year 2010.
3. Create a Test class and Check if it is working properly or not
4. To check whether the job is Scheduled or not GOTO Setupà Administration Setup à Monitoring à Scheduled Jobs
You can find all the Scheduled jobs here and there start and next run details.
//For Reference check salesforce_apex_language_reference_18.0.pdf – Apex Scheduler
Anonymous Block
An anonymous block is an Apex script that does not get stored in the metadata, but that can be compiled and executed.
Compilation and Execution can be done using the Following:
1. System Log console
2. Force.com IDE
3. The executeAnonymous Force.comWeb Services API call:
ExecuteAnonymousResult executeAnonymous(String code)
Note the following about the content of an anonymous block (for executeAnonymous, the code String):
• Can include user-defined methods and exceptions.
• User-defined methods cannot include the keyword static.
• You do not have to manually commit any database changes.
• If your Apex script completes successfully, any database changes are automatically committed. If your
Apex script does not complete successfully, any changes made to the database are rolled back.
• Unlike classes and triggers, anonymous blocks execute as the current user and can fail to compile if the
script violates the user's object- and field-level permissions.
• Do not have a scope other than local. For example, though it is legal to use the global access modifier,
it has no meaning. The scope of the method is limited to the anonymous block.
executeanonymous() : Executes a block of Apex
Syntax:
ExecuteAnonymousResult[] = binding.executeanonymous(string apexcode);
The executeanonymous() call returns information about whether or not the compile and run of the code was successful.
The ExcuteAnonymousResult has the properties which tells us that if there is a compilation error then at which column number, line and what type of exception has occurred. If Success then it results true.
Implementation Details in Force.Com IDE:
1. Create a webservice class which has to be executed anonymously.
Example:
global class LocationSample{
webService static boolean getLocation(string strLocation){
boolean oppExistInCw = false;
//query Location__c Custom Object to search for related Address
Location__c loc=[Select Name, city__c, country__c,
Street_Address__c from Location__c where Name=:strLocation];
if(loc!=null) {
//update Postal Field
loc.Postal_Code__c = '500036';
update loc;
oppExistInCw = true;
return oppExistInCw;
}else{
return oppExistInCw;
}
}
}
2. Once Webservice class has been created then goto ExecuteAnonymous block
3. Once it is successful then the changes will be committed as per your code.
Salesforce401Question & Answers
- In the statement below, controller refers to what type of controller? Select the one correct answer. <apex:page controller="AccountController">
- Standard Controller
- Custom Controller
- Controller Extension
- Specific Controller
- Which of the following represent correct syntax to display first name from global variable user? Select the one correct answer.
- {User.FirstName}
- {!User.FirstName}
- $User.FirstName
- {!$User.FirstName}
- Which of these is not a standard profile? Select the one correct answer.
- Developer
- Contract Manager
- Read only
- Solution Manager
- Name the language Force.com uses to support full-text search in objects. Select the one correct answer.
- SQL
- VisualForce
- SOQL
- SOSL
- Before a code can be deployed on production what percentage of test coverage must be achieved. Select the one correct answer.
- 25%
- 50%
- 75%
- 100%
- In Salesforce what is the maximum number of fields that can be added to an object? Select the one correct answer.
- There is no such limit on the number of fields
- 100
- 200
- 500
- How many characters are there in the Salesforce case-insensitive id field of an object? Select the one correct answer.
- id field is not mandatory
- The field length is customizable
- This depends on the version of Salesforce
- 18
- Name the prefix used by standard VisualForce markup tags. Select the one correct answer.
- vf
- apex
- c
- s
- Which of the following cannot be included in a VisualForce page? Select the one correct answer.
- Java
- JavaScript
- HTML
- Flash
- To create a new VisualForce page HelloWorld in developer mode, which URL should be appended to server address? Select the one correct answer.
- /HelloWorld
- /vf/HelloWorld
- /apex/HelloWorld
- /home/HelloWorld
- What is the maximum size of a VisualForce page? Select the one correct answer.
- 1 MB
- 5 MB
- 15 MB
- There is no limit on the size of a VisualForce page
- What is the number of components that can be added to a dashboard? Select the one correct answer.
- 20
- 25
- 50
- 100
- Which of these represent the correct syntax for custom controllers? Select the one correct answer.
- <apex:page controller="MyController">
- <apex:page standardController="MyController">
- <apex:page customController="MyController">
- <apex:page privateController="MyController">
- Which is the first step when creating reports? Select the one correct answer.
- Select report name
- Select object on which report needs to be generated
- Select type of report
- Select columns to be displayed
- Which of these is not a valid report type. Select the one correct answer.
- Summary
- Matrix
- Tabular
- Detailed
- Which report type is used to group rows of data and show their subtotals. Select the one correct answer.
- Summary
- Matrix
- Tabular
- Detailed
- Which report type is used to group rows and columns of data and show their subtotals. Select the one correct answer.
- Summary
- Matrix
- Tabular
- Detailed
- Which report type does not allow generation of charts? Select the one correct answer.
- Summary
- Matrix
- Tabular
- Detailed
- Which of these are valid data type in Force.com development platform. Select the two correct answers.
- Percent
- URL
- Choicebox
- Long
- Decimal
- When designing an application, a developer needs to make a field editable to all profiles. In field level security what settiings should be used in this situation. Select the one correct answer.
- Disable Visible and Read-Only
- Disable Visible but Enable Read-Only
- Enable Visible but Disable Read-Only
- Enable Visible and Read-Only
- Which report type does not support analytical snapshot? Select the one correct answer.
- Summary
- Matrix
- Tabular
- Detailed
- A customer has requested a user interface where list view of four objects can be accessed together with frequent navigation across them. Which feature of Force.com platform can be used to support this requirement? Select the one correct answer.
- Console
- Dashboards
- Analytical Snapshot
- Packages
- Layout template
- In a recruitment application, a dashboard component needs to be built that will display total number of positions. Which dashboard component can be used to implement this feature? Select the one correct answer.
- Gauge
- Metric
- Table
- Chart
- VisualForce page
- Universal Recruiters will like to hire ten employees in two months. In a recruitment application, a dashboard component needs to be built that will display progress towards achieving this goal of hiring of ten employees. Which dashboard component can be used to implement this feature? Select the one correct answer.
- Gauge
- Metric
- Table
- Chart
- VisualForce page
- Universal Recruiters uses an external system for keeping track of exits from the organization. The CEO of the organization will like to view information about exits in the Salesforce application that Universal Recruiters uses. Which dashboard component can be used to implement this feature? Select the one correct answer.
- Gauge
- Metric
- Table
- Chart
- VisualForce page
- Universal Recruiters uses Force.com as its recruitment platform. The Sales VP of Universal Recruiters will like a report that will display progress in recruitment across six months. Which reporting component can be used to implement this feature? Select the one correct answer.
- Summary
- Matrix
- Tabular
- Analytic Snapshot
- Which two features are supported by Salesforce in developer mode? Select the one correct answer.
- Developer mode allows a default user interface to be created for objects.
- Developer mode provides a debugger that is used to perform step by step execution.
- Developer mode allows developers to create dashboards from reports.
- Developer mode allows split screen where user can view Visual Force editor and user interface together
- Developer mode allows developers to create new pages by just entering the page name.
- Universal Recruiters wants to make access to records in such a way that all managers should be able to access records that are accessible to their team members. Which feature of Force.com's security should be used to implement this requirement. Select the one correct answer.
- Object level access to profiles
- Field level access to profiles
- Organization wide defaults
- Role hierarchy
- Sharing rules
- Manual sharing
- Universal Recruiters need to ensure that the Social Security Number and Phone Numbers follow a specific pattern. Which function can be used to implement this functionality. Select the one correct answer.
- REGEX
- EXPRMATCH
- ISNUMBER
- PRIORVALUE
- VLOOKUP
- Universal Recruiters have an object that they use to store all US zip codes and corresponding states. They want to ensure that the zip code and state specified by users are correct. Which function could be used to implement this feature? Select the one correct answer.
- REGEX
- EXPRMATCH
- ISNUMBER
- PRIORVALUE
- VLOOKUP
- Which of these functions is available in formulae field. Select the one correct answer.
- ISCHANGED
- ISNEW
- REGEXC
- IF
- VLOOKUP
- All of these functions are available in a formula field
- A Force.com developer needs to execute Apex code snippet and check the resource usage. Which feature of the platform can be used to support this requirement. Select the one correct answer.
- Debug Log
- System Log
- Setup Audit Trail
- Field level security
- A user at Universal Container has reported an issue with respect to approval process. You need to analyze this issue by reviewing the debug messages that get generated for this particular users. Which feature of the platform can be used to support this requirement. Select the one correct answer.
- Debug Log
- System Log
- Setup Audit Trail
- Field level security
- While debugging an issue you realize that the field type of an object has changed. You need to find out more details about this change. Which feature of the platform can be used to support this requirement. Select the one correct answer.
- Debug Log
- System Log
- Setup Audit Trail
- Field level security
- In Universal Recruiter application a developer realizes that the Salary field of an employee is set up to an incorrect value. The developer needs to find out who has set this new value to Salary field. Which feature of the platform can be used to support this requirement. Select the one correct answer.
- Debug Log
- System Log
- Setup Audit Trail
- Field level security
- Which of the following is correct about custom fields in Salesforce. Select one correct answer.
- If a field is set as required it must be entered in the Salesforce generated pages, however it may not be specified when entering information via Force.com API
- A required field is always present in an edit page
- A unique field is always present in an edit page
- A unique field increases report and SOQL performance
- Fields of the which of the following type is not allowed to be set as external ids. Select one correct answer.
- Date
- Number
- Text
- The number of master detail relationship that an object can have are
- 1
- 2
- 25
- 300
- The number of Lookup relationship that an object can have are
- 1
- 2
- 25
- 300
- Which of these is true about the Lookup Relationship. Select one correct answer.
- Parent is not a required field and may be omitted.
- Deleting an object deletes its children.
- Roll-up summary field can be used to perform basic operations over all children of a parent record.
- Security access of the child record is dependent upon the parent record.
- Which of the following cannot be used to build a complete Custom Tab. Select one correct answer.
- Display an external web page
- Display data using a VisualForce page
- Show data from a custom object using the native user interface
- Display the approval process using an Apex page
- Which of the following is not supported by Enhanced Page Layout editor. Select the one correct answer.
- Change the field name
- Add blank spaces
- Make a field required or read-only
- Add a new section
- Add a new custom field
- Which of the following is true about Roll-up summary fields? Select one correct answer.
- Roll-up summary can only be set on the parent of a Master-Detail or Lookup relationship.
- Roll-up summary can be used to compute SUM,MIN,MAX,AVG over a set of records
- The results of the roll-up summary is displayed on the child in a master-detail relationship.
- Roll-up summary fields are read only.
- Which of the following is true about Validation Rules? Select two correct answers.
- Validation rules are executed when the user clicks on the Save button.
- Validation rules are not applicable when the data is stored using the API.
- If the error condition evaluates to true, then an error message is generated and the record is not saved.
- Validation rules are applied only when a new record is created, and not when an existing record is edited.
- Which of the following is not a valid return type of a custom formula. Select one correct answer.
- Date
- Decimal
- Text
- Array
- Which of the following is not a part of a Force.com app. Select one correct answer.
- Notes
- Tab
- Links
- Forms
- An organization needs to create a public website that displays data from Salesforce.com organization without user registration. Select one correct answer.
- Apex
- Triggers
- Salesforce Knowledgebase
- Force.com sites
- Formula
Answers
- B. controller attribute is used for Custom Controller
- D. {!$User.FirstName} is the correct syntax to access first name.
- A. There is no developer standard profile.
- D. Salesforce Object Search Language
- C. The code must get a test coverage of 75% before it can be deployed.
- D. There can be a maximum of 500 fields in custom objects.
- D. object id field can be 15 character case-sensitive or 18 character case-insensitive.
- B. The prefix apex is used for standard VisualForce markup tags.
- A. It is not possible to include Java code in VisualForce page.
- VisualForce page address appears like /apex/HelloWorld.
- C. VisualForce pages must be upto 15 MB.
- A. A dashboard can have upto 20 components.
- A.
- B. The first step when creating reports is select the object type.
- D. Salesforce does not have a report type named Detailed.
- A.
- B.
- C.
- A, B. Percent and URL are valid data types in Salesforce.
- C. To make a field editable, enable Visible but disable Read-Only.
- B. Matric report cannot be used to generate Analytical snapshot.
- A. Console tab allows easy navigation across multiple object types.
- B. Metric dashboard type is used to display
- A. A gauge is used to display progress towards a goal.
- E. VisualForce pages can be used to draw dashboard components that extract data from another source.
- D. Analytic Snapshot feature of Salesforce is used to perform trend analysis over a period of time.
- D, E. Last two statements about developer mode are correct.
- D. Role Hierarchy feature of Force.com platform can be used to implement this functionality.
- A. REGEX function is used to check a text field matches the regular expression.
- E. VLOOKUP is used to return the value for a unique key in an object.
- D. IF function is available in the formula field. Other functions are not available in the formula field.
- B. System Log can be used to run code snippets.
- A. Debug Log can be used to view the debug/error messages generated for a particular user.
- C. Setup Audit Trail can be used to track changes made in the configuration.
- D. Field History Tracking can be used to find out changes in field values.
- B. A field set as required must always be present in the edit page.
- A. Fields of type external id can be defined as Text, Number or Email.
- B. An object can have maximum of 2 Master detail relationship
- C. An object can have maximum of 25 Lookup relationship
- A. Parent is not a required field in Lookup relationship
- D. Custom tabs can be used to display a VisualForce page, data from an external page, data from a custom object.
- E. Enhanced Page Layout editor cannot be used to create new fields.
- D. Only option D is correct. Rollup summary field can only be applied in Master-detail. Hence A is incorrect. AVG is not supported in Rollup summary fields.Rollup Summary is defined at the parent level of a Master-Detail relationship.
- A and C. Validation rules are applicable when the record is saved using the API, hence the option B is incorrect. Validation rules are applied every time the record is saved, hence D is incorrect.
- D. Array is not a valid return type of custom formula.
- A. Key element of a Salesforce app are Tab, Links and Forms.
- D. Force.com sites is used to build public facing sites.
- 1. ID's are identical in :
- A. Production, full copy sandbox, developer
- B. Production and full copy sandbox only
- C. Production , developer
- 2. If you want to look at trends in a report which report would you use:
- A. Matrix
- B. Summary
- 3. If you want the a list of positions what dashboard would you use:
- A. metric
- B. table
- C. chart
- D. gauge
- 4. how many master detail relationships can you have on an object:
- A. 4
- B. 2
- C. 1
- D. 3
- 5. What would you use an apex trigger for...
- A. have a zip code object and in the city and state of the
- candidate position to check the zip code table and see if that
- city exist in the state
- B. create new record, have it update a field
- 6. What is a Mini page layout or related list?
- 7. Know everything about an external id.
- 8. Know the ins and out of the search component on the side bar
- 9. What versions have apex and vf both active:
- 10. For the user object what can you do in the page layout:
- A. custom link
- B. inline vf page
- C. custom button
- D. custom field
- 11. A CEO does not want to log into salesforce.com but would
- like see the dashboards.
- How would one accomplish this? How would one set this up?
- 12. When one wants to lock the records:
- A. is this process automated
- B. One needs to choose this option when doing an approval process.
- 13. Profiles and what do they give access to?
- 14. Sharing and revoking grant access
- 15. The import wizard and user object
- 16. Force.com metadata api
- 17. What represents the view in MVC
- 18. Organization wide defaults
- 19. Public read/write, public read only
- 20. If the approval process sents out 3 emails simultaneously to managers.
- What is the next step in the approval process and how does it get to
- the next step?
- 21. Parent child relationship
- 22. Many many replationship
- 23. Manager wants to give access to data reporting to his team
- what access is required for this to happen:
- A. reports, dashboard folder
- B. reports dashboard user running
- 24. Encryted field not good for :
- 25. Workflow rules
- 26. Today()-Datevalue(CreatedDate)
- 27. For approval process what groups can you have:
- A. profiles
- B. roles and subordicates
- C. active team members
- 28. Org wide defaults / hierarchy turned off
- 29. Page Layout can you add inline vf
- 30. Record types
- 31. Is there such a thing called minipagelayout
- 32. Who can change the owner of a record
- 33. How does a developer test out the time trigger workflow rule
- does he do it through:
- A. debug log.
- B. sign in as the developer name, create new record,
- go to the time trigger queue
- 34. Creating a lookup relationship
- 35. What are the three actions for a workflow process the beggining steps
- 36. Do you give permissions to submit for approval button,
- Or is it added on automatically?
- 37. Dataloader: 50,000 more records at a time. True or False
- 38. Developer used dataloader and try to load into sandbox
- but had an issue had authentication issue
- What could it be:
- A. Password encryption
- B. Chk username
- C. chk endpoint
- 39. What is a Declarative interface?
- 40. What is localize and internationalize?
- 41. What does out of the box salesforce give you?
- A. data warehouse
- B. approval process
- C. workflow rules
- D. validation rules
- 42. Know this page.Inside out.
- 43. Apex Dataloader and Import wizard through salesforce.com
- For Apex Dataloader Go Into:
- Setup|Administrative Setup|Data Management| DataLoader (See Below)
http://forceprepare.com/developermock.html
Subscribe to:
Posts (Atom)
What’s the difference between Einstein Article Recommendations and Suggested Articles?
How Does Einstein Article Recommendations Work? Einstein Article Recommendations helps support agents resolve customer cases efficiently by ...
-
Hi, To get the current recordId when we create a quick action with LWC we have to use the below code snippet. _recordId ; set recordId ( ...
-
Hi , Here we are going to learn how to generate JSON with the help of Map in apex. Let's take the following JSON and see how to generat...