Posts

Showing posts from 2013
Image
Error: MIXED_DML_OPERATION Few days back while writting an test class I encounterd an Error stating  System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa):     You will get this Error if you are trying to perform DML on setup and non-setup objects in same Transaction.  Non-Setup objects can be any one of the Standard objects like Account or any Custom objcets, Below are few examples of Setup objects 1.  FieldPermissions 2.  Group You can only insert and update a group in transaction with   other SObject . Other DML operations are not allowed .   3.  GroupMember You can only insert and update a group member in a transaction with other sObjects in Apex Code saved using Salesforce.com API version 14.0 and earlier.   4.  ObjectPermissions 5.  Permissio...
Image
Salesforce Public Calendar and Resource In salesforce we can create an event and that event get displayed on salesforce calendar but what will happen when you want to block an event in some conference room and do not want that conference room should get block by another event on same day and at same time.              We can acheive that using salesforce resource which is actually a very little but useful functionality of Salesforce which is always been overlooked. Using this functionality we can manage office resource, projectors, meetings etc. As according to Salesforce :  "In contrast to users’ individual calendars, public and resource calendars are for managing group activities or shared resources. You can create an unlimited number of calendars ." To add public calendar or resource : 1. Go to Setup > Customize > Activities > Public Calendar and     Resources. 2. Either create new Public Calendar ...
Image
Calculate number of years in formula field If you want to calculate number of years between two dates like calculating someone's age in years from his/her birthdate, you can do it using formula field.  Create a formula field and select return type a number, don't forget to select decimal place to 0. Now in Formula field editor write below formula.  Explaination: IF condition first checks if month of present year is greater than date of birth, if condition is true then age will be calculated as the difference between present year and year of birth, but if condition is false then second IF condition is calculated according to which if month of two dates are same or taday's day is larger than or equal to the day of date of birth then age is calculated as in the first scenario [ YEAR(TODAY()) - YEAR(TODAY()) ] . If these also fail then age is calculated as the difference between present year and year of birth, subtracting 1  [ YEAR(TODAY()) - YEAR(DOB__c)...
Image
Email and Phone Validation Suppose you have created a picklist named Type where you are giving an option of selecting Email or Phone and entering the value in text field and want to validate that text field depending on the value of value selected in picklist. You can achieve this by creating a simple validation rule You have Two fields Type : Picklist value with values Business Email Address Private Email Address Home Phone Mobile Phone Work Phone    2. Value : Text Field All you have to do is to create a validation rule on Value function used: IF(logical_test, value_if_true, value_if_false) :   Checks whether a condition is true, and returns one value if TRUE and another value if FALSE. ISPICKVAL(picklist_field, text_literal) : Checks whether the value of a picklist field is equal to a string literal REGEX(Text, RegEx_Text) : Returns TRUE if Text matches the regular expression RegEx_Text. Otherwise, it returns FALSE....
Randomly Generate Html Color Are you fed up of copying Hex color code and changing it again and again and do you want to Generate Html Color code randomly, you can acheive this using following javascript code. <script>     function get_random_color() {         var letters = '0123456789ABCDEF'.split('');         var color = '#';         for (var i = 0; i < 6; i++ ) {             color += letters[Math.round(Math.random() * 15)];         }         document.getElementById("in").setAttribute('style','background-color:' +color);     } </script> I am generating the color randomly on click of button. <div id="d">   <input type="text" id="in"/>   <input type="button" onClick="get_random_color();" value="generate"/> <...
Image
Style your Button Fed up with your look and feel of your old buttons and wanted to add more appeal to your html button then I will show you the way to get rid of that old boring style button.    In your Input button <input type="button" value="Button" id="btn" /> You just have add this CSS: and you will get a new Stylish button, modified it further as you want. Want to learn more, Go to http://www.red-team-design.com/just-another-awesome-css3-buttons
Image
How to Use vLookup in Excel Many Times I find people struggling to use vLookup in excel as they find it difficult. So today I will tell you how can you use vLookup in Excel and for demo we will be using vlookup for two different Excel sheets. I have created two reports 1. Account with Contacts (Account and Contact.csv) 2. Account with Opportunity (Account and Opportunity.csv) and export them. We will use vLookup function to get Account Name From Sheet 2(" Account and Opportunity") to Sheet 1(" Account and Contact") Step 1.write =vlookup( in a cell where you want to find out the value.  You can also try this with clicking fx present. Step 2. Click on cell A3 as we want to find out the Account name for that cell.On clicking you will see 'A3' automatically populated inside vlookup() function.       Step 3. Now go to second sheet and select the columns where you want to search the Account name for t...