SOLUTIONS WITH BEST POSSIBLE OPTIONS
Friday, April 19, 2013
One to One Relationship in Salesforce
We all know about the 1-M && M-M relationship(using junction Object) in salesforce.
Some times we may need 1-1 relationship among two objects.
but Unfortunately Salesforce doesnot allow any direct methodolgy to build 1-1 relationship
We can achieve the same by workflow or trigger. But workflow is more flexible & the easier way
Steps
-------
Say Two Objects OBJECT-A and OBJECT-B
1- create a look up field in one object
say in OBJECT-A, there is a lookup to OBJECT-B
field Name= obj-B (say)
2- Create another textfield at same Object with unique property (used to hold same obj-B field value)
fieldName= unique_Obj-B (say)
3- Define a workFlow Rule /Trigger to Update the custom "unique_Obj-B" field with the value of the associated OBJECT-B ID.(i.e the field value of "obj-B")
Now we have done with 1-1 Relationship
When we try to add a second same OBJECT-B to the OBJECT-A, the "unique" constraint in OBJECT-A (field "unique_Obj-B")would be violated and an error would be thrown.....
Thursday, April 18, 2013
Triggers and Order of Execution
Few days back I faced a situation , in which it was needed to update a field depending upon a Roll-up Summary field Value through trigger.
FYI we can not get the RollUpSummary field value inside trigger, because of sequence of execution of trigger(after, before) & RollUpSummary field value.
So here I am posting sequence of Trigger , automation rules ,validation rule etc execution 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
5- Custom Validation Rules
6- Record saved to database (but not committed)
7- Record reloaded from database
8- All Apex “after” triggers
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)
For Detail explanation please refer
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm
notes: There is no way to control the order of execution within each group above
Tuesday, February 26, 2013
How To Display Inline Help Text of a SObject field in Visual Force Page
Most of the time when we override Visualforce page, clients/Users many time demand for same Standard page layout inline Help Text bubbles.
apex:inputField and apex:outputField shows their help Text bubble when nested within a pageBlockSection component automatically.
However, there are scenario when helpText Bubble is not displayed at VF page
scenario
----------
1- If we use "Label" attribute of "apex:outputField" , then helpText bubble is not displayed
2- If we set "showHeader=false" of <aapex:Page>, in that case also helpText bubbles is not displayed
We can access the help text within an expression by using the respective $ObjectType global as such:
$ObjectType.Account.Fields.myField__c.inlineHelpText
So I came up with my own idea to display help text at VF page with above two scenarios
<div id="mainContent">
Sample helpText Example
<span class="Custom ToolTip text">
<img src="/s.gif" alt="Help" class="helpIcon" title="$ObjectType.Account.Fields.myField__c.inlineHelpText"/>
</span>
</div>
By Providing "$ObjectType.Account.Fields.myField__c.inlineHelpText" in TITLE attribute of <img> tag..the helpText will be displayed as ToolTip Text
Thursday, January 3, 2013
Collapse PageBlockSection by default on page load
Collapse
PageBlockSection by default on page load
In
a normal Salesforce VF page, the PageBlock Section is not collapsed at the time
of page loading.
But
some times we want a pageblock section to be collapsed by default at the time
of page loading.
We
can do this, with some tricky javascript. We have to get a javascript function
that is a document "onload" handler to call "twistSection"
on the image that is the little twist control for the page block section.
Please
try the following post , which will Collapse PageBlockSection by default on
page load
VF
Code:
------------
<apex:page
tabStyle="MyObject__c" id="myPage">
<script
language="javascript">
/**
<!-- Collapse PageBlockSection on Page Load-->
**/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
function
dotest() {
if(document.getElementById('myPage:myForm:myBlock:mySection') !=
null){
twistSection(document.getElementById('myPage:myForm:myBlock:mySection').childNodes[0].childNodes[0]);
}
}
addLoadEvent(dotest);
</script>
<apex:form
id="myForm">
<apex:pageBlock
id="myBlock">
<apex:pageBlockSection
title="CollapsablePageBlockSection" collapsible="true"
id="mySection">
Mindfire
Solutions
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form
>
</apex:page>
Subscribe to:
Posts (Atom)