1. While developing your
Visualforce pages you may need to be able to obtain the URL of certain actions,
s-controls or your static resources.
I found it personally a challenge since the documentation for "URLFOR" function is not included in "Visualforce Developer Guide" itself and instead included in the general help area of Salesforce.
Generally you can use the "URLFOR" function for three purposes:
I found it personally a challenge since the documentation for "URLFOR" function is not included in "Visualforce Developer Guide" itself and instead included in the general help area of Salesforce.
Generally you can use the "URLFOR" function for three purposes:
1.
Obtain URL of a
s-control
2.
Obtain URL of a static
resource
3.
Obtain URL of an
object's action
In
this article I will demonstrate usages of the three above.
Generally, URLFOR function returns a relative URL for an action, s-control, or a file in a static resource archive in a Visualforce page. Following the syntax of the function:
{!URLFOR(target, id, [inputs], [no override])}
Parameters shown in brackets ([]) are optional.
Generally, URLFOR function returns a relative URL for an action, s-control, or a file in a static resource archive in a Visualforce page. Following the syntax of the function:
{!URLFOR(target, id, [inputs], [no override])}
Parameters shown in brackets ([]) are optional.
·
target: You can replace target with a URL or action,
s-control or static resource.
·
id: This is id of the object or resource name
(string type) in support of the provided target.
·
inputs: Any additional URL parameters you need to pass you can use this
parameter.
you will to put the URL parameters in brackets and separate them with commas
ex: [param1="value1", param2="value2"]
you will to put the URL parameters in brackets and separate them with commas
ex: [param1="value1", param2="value2"]
·
no
override: A Boolean value
which defaults to false, it applies to targets for standard Salesforce pages.
Replace "no override" with "true" when you want to display
a standard Salesforce page regardless of whether you have defined an override
for it elsewhere.
Obtaining URL of a s-control:
<!-- Use $SControl global veriable to reference your s-control
and pass it to the URLFOR function -->
<apex:outputLink value="{!URLFOR($SControl.MySControlName)}">Link to my S-Control</apex:outputLink>
Obtaining URL of a Static Resource
<!-- Use $Resource global veriable to reference your resource
file -->
<apex:image url="{!URLFOR($Resource.LogoImg)}" width="50" height="50" />
<!-- If your file is in another ZIP file, then pass the path of
the file as id to URLFOR -->
<apex:image url="{!URLFOR($Resource.CorpZip, 'images/logo.gif')}" width="50" height="50" />
Obtaining URLs of an Object's Actions:
In order to get URL of the an object's actions you need to know what actions that object supports. Below are some of the common actions most Objects support:
·
View: Shows the detail page of an object
·
Edit: Shows the object in Edit mode
·
Delete: URL for deleting an object
·
New: URL to create a new record of an object
·
Tab: URL to the home page of an object
However, each object
may support additional actions for example Contactalso supports
"Clone" action and Case supports
"CloseCase" action.
<!-- Use $Action global varialble to access the New action
reference -->
<apex:outputLink value="{!URLFOR($Action.Account.New)}">New</apex:outputLink>
<br/>
<!-- View action requires the id parameter, a standard
controller can be used to obtain the id -->
<apex:outputLink value="{!URLFOR($Action.Account.view, account.id)}">View</apex:outputLink>
<br/>
<!-- Edit action requires the id parameter, id is taken from
standard controller in this example -->
<apex:outputLink value="{!URLFOR($Action.Account.Edit, account.id)}">Edit</apex:outputLink>
<br/>
<!-- Delete action requires the id parameter, also a confirm
message is added to prevent deleting the record when clicked by mistake -->
<apex:outputLink value="{!URLFOR($Action.Account.delete, account.id)}" onclick="return
window.confirm('Are you sure?');">Delete</apex:outputLink>
<br/>
<!-- From all custom buttons, links, s-controls and visualforce
pages you can use the following to get the link of the object's homepage -->
<apex:outputLink value="{!URLFOR($Action.Account.Tab,
$ObjectType.Account)}">Home</apex:outputLink>
Posted 17th December 2013 by vikramSFDC
0
Add a comment
Vikram
sfdc
1. What is Apex
Ans: It is the
in-house technology of salesforce.com which is similar to Java programming
with object oriented concepts and to write our own custom logic.
2. What is S-Control ?
Ans: S-Controls are the predominant salesforce.com widgets which are completely based on Javascript. These are hosted by salesforce but executed at client side. S-Controls are superseded by Visualforce now.
Ans: S-Controls are the predominant salesforce.com widgets which are completely based on Javascript. These are hosted by salesforce but executed at client side. S-Controls are superseded by Visualforce now.
3. What is a
Visualforce Page ?
Ans: Visualforce is the new markup language from salesforce, by using which, We can render the standard styles of salesforce. We can still use HTML here in Visualforce. Each visualforce tag always begins with “apex” namespace. All the design part can be acomplished by using Visualforce Markup Language and the business logic can be written in custom controllers associated with the Page.
Ans: Visualforce is the new markup language from salesforce, by using which, We can render the standard styles of salesforce. We can still use HTML here in Visualforce. Each visualforce tag always begins with “apex” namespace. All the design part can be acomplished by using Visualforce Markup Language and the business logic can be written in custom controllers associated with the Page.
4. Will Visual force
still supports the merge fields usage like S-control ?
Ans: Yes. Just like S-Controls, Visualforce Pages support embedded merge fields, like the {!$User.FirstName} used in the example.
Ans: Yes. Just like S-Controls, Visualforce Pages support embedded merge fields, like the {!$User.FirstName} used in the example.
5. Where to write
Visualforce code ?
Ans: You can write the code basically in 3 ways.
Ans: You can write the code basically in 3 ways.
1. setup->App Setup->Develop->Pages and
create new Visulaforce page.
2. Setup -> My Personal Information ->
Personal Information -> Edit check the checkbox development mode. When you
run the page like this, https://ap1.salesforce.com/apex/MyTestPage. you will find the Page editor at the bottom
of the page. You can write you page as well as the controller class associated
with it, there it self.
3. Using EclipseIDE you can create the
Visulaforce page and write the code.
6.What are Apex
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.
Types of limits that Apex enforces are resources like memory, database
resources, number of script statements to avoid infinite loops, and number of
records being processed. If code exceeds a limit, the associated governor
issues a runtime exception.
7. How to create and
host S Control in Salesforce ?
8. Difference between
Sandbox and Development environment?
9. How to schedule
export or take the backup of salesforce?
http://shivasoft.in/blog/webtech/salesforce/backup-the-salesforce-data/
10. Do governor limits apply to sandbox instances?
10. Do governor limits apply to sandbox instances?
Ans : Governor limits do apply to all
Salesforce instances (trial, developer, production or sandbox environments).
However code coverage and successful execution of test classes is only enforced
when deploying to a production environment.
11. What is difference
in ISNULL and ISBLANK?
ISNULL:
· Determines if an expression is null (blank)
and returns TRUE if it is. If it contains a value, this function returns FALSE.
· Text fields are never null, so using this
function with a text field always returns false. For example, the formula field
IF(ISNULL(new__c) 1, 0) is always zero regardless of the value in the New
field. For text fields, use the ISBLANK function instead.
· Multi-select picklist fields are never null in
s-controls, buttons, and email templates, so using this function with a
multi-select picklist field in those contexts always returns false.
· Empty date and date/time fields always return
true when referenced in ISNULL functions.
· Choose Treat blank fields as blanks for your
formula when referencing a number, percent, or currency field in an ISNULL
function. Choosing Treat blank fields as zeroes gives blank fields the value of
zero so none of them will be null.
· Merge fields can be handled as blanks, which
can affect the results of components like s-controls because they can call this
function.
· When using a validation rule to ensure that a
number field contains a specific value, use the ISNULL function to include
fields that do not contain any value. For example, to validate that a custom
field contains a value of ’1,’ use the following validation rule to display an
error if the field is blank or any other number: OR(ISNULL(field__c),
field__c<>1)
ISBLANK:
· Determines if an expression has a value and
returns TRUE if it does not. If it contains a value, this function returns FALSE.
· Use ISBLANK instead of ISNULL in
new formulas. ISBLANK has the same functionality as ISNULL, but also supports
text fields. Salesforce.com will continue to support ISNULL, so you do not need
to change any existing formulas.
· A field is not empty if it contains a
character, blank space, or zero. For example, a field that contains a space
inserted with the spacebar is not empty.
· Use the BLANKVALUE function to return a
specified string if the field does not have a value; use the ISBLANK function
if you only want to check if the field has a value.
· If you use this function with a numeric field,
the function only returns TRUE if the field has no value and is not configured to
treat blank fields as zeroes.
12. Is it possible to
write the Apex code from user Interface?
You can add, edit, or
delete Apex using the Salesforce.com user interface only in
a Developer Edition organization, a Salesforce.com Enterprise Edition
trial organization, or sandboxorganization. In a Salesforce.com production
organization, you can only make changes to Apex by using
the Metadata API ,
deploycall, the Force.com IDE, or theForce.com
Migration Tool. The Force.com IDE and Force.com Migration
Tool are free resources provided by salesforce.com to support its users and partners, but
are not considered part of our Services for purposes of the salesforce.com Master Subscription Agreement.
13. When you can’t add
Time dependent action in Workflow rule?
You can’t add time-dependent actions to a rule if you choose Every time a record is created or edited.
You can’t add time-dependent actions to a rule if you choose Every time a record is created or edited.
1. Text
2. HTML with Letter Head
3. Custom HTML
4. Visual force
15. What are the
different Salesforce.com Editions and Limits?
Ans : check this URL
16. What is Roll up
summary field in Salesforce?
Roll up summary field
in salesforce calculates the Count, Sum, Min or Max of
particular field of any child record. Thus, we can say that Roll up summary
field can only be created on Master object. To
read further, please check this URL
17. What will happen
if the Account is deleted?
If the Account is
deleted then Contact, Opportunity will also be deleted from Salesforce which
are related to that Account.
From the database
perspective, check below image of child relationships of Account:
Account Child
relationship in salesforce
If we use schema
builder, released in Winter 12 it would look like:
Account Contact and
Opportunity of salesforce in schema builder
18. How many types of
the relationship fields available in Salesforce?
Ans :
1. Master Detail
2. Many to Many
3. Lookup
4. Hierarchical (It is available only on User
Object, we cannot create this relationship)
19. How to create many
to many relationships between object?
Creating many to many
relationship in salesforce is little tricky. You cannot create this type of
relationship directly. Follow below steps to create this type of relationship.
Create both objects
which should be interlinked.
Create one custom
object (also called as junction object), which should have
autonumber as unique identification and create two master
relationships for both objects, no need create tab for this object.
Now on both object,
add this field as related list.
20. In Which sequence
Trigger and automation rules run in Salesforce.com The following is the order salesforce
logic is applied to a record.
1. Old record loaded from database (or initialized
for new inserts)
2. New record values overwrite old values
3. System Validation Rules
4. All Apex “before” triggers (EE / UE only)
5. Custom Validation Rules
6. Record saved to database (but not committed)
7. Record reloaded from database
8. All Apex “after” triggers (EE / UE only)
9. Assignment rules
10. Auto-response rules
11. Workflow rules
12. Escalation rules
13. Parent Rollup Summary Formula value
updated (if present)
14. Database commit
15. Post-commit logic (sending email)
Additional notes:
There is no way to control the order of execution within each
group above.
21. If one object in
Salesforce have 2 triggers which runs “before insert”. Is there any way to
control the sequence of execution of these triggers?
Ans : Salesforce.com has documented that trigger
sequence cannot be predefined. As a best practice create one trigger per
object and use comment blocks to separate different logic blocks. By having all
logic in one trigger you may also be able to optimize on your SOQL queries.
22. How to delete the
User from Salesforce?
Ans : As per now, salesforce does not allow to
delete any user, however you can deactivate the user.
Thanks for sharing this commmands, it gives lots of information to me.
ReplyDeleteSalesforce course in Chennai | Salesforce Training Chennai