Category: Salesforce
Salesforce | Calculate number of years between two dates in apex class
Sample Code: Date date1 = System.today(); Date date2 = System.today().addMonths(30); system.debug(‘No of months === >>>> ‘ + date1.monthsBetween(date2)); String noOfYears = String.valueOf(date1.monthsBetween(date2) / 12) + ‘ Year(s) ‘ + String.valueOf(Math.mod(date1.monthsBetween(date2), 12)) + ‘ Month(s)’; system.debug(‘No of years ‘ + noOfYears);
Salesforce | Visualforce | Error : DML currently not allowed exception on creation of the record on an Object
When creating a record on the document object using Rest API, Salesforce did not allow to execute the DML command from the Visualforce component. Reason: When we try to pass dynamic values from the Visualforce Component to the Apex method,
Mysql | How to access database remotely
To access Mysql database remotely a good way is to create a new Mysql user and grant it permissions to access database from remote, as explained below: You can create user with two ways From Mysql command prompt: 1. Open
List of English phrases that can confuse the reader
1. A penny for your thoughts: A way of asking what someone thinks about something. Example: The new Salesforce Internet of Things (IoT) can be the next big thing, a penny for your thoughts? 2. Back to the drawing board: When an attempt
HTML | WordPress | pre tag not working
When pre tag is used in WordPress to include code which contains tags like apex, pre does not work. For Example: <apex:page standardController=”Event”> The above code displays empty screen when used in the pre tag. Solution: Replace < with <
Javascript | Unable to get content of HTML while converting HTML page to PDF
Problem : Unable to get content of HTML while converting HTML page to PDF. Solution : You can use the javascript if you want to get content of HTML while converting it into PDF : <HTML> <head> <script type=”text/javascript”> function submitForPDF() {
HTML text box should only accept numbers and dot
You can use the following javascript code to check textbox value: <html> <head> <script language=”Javascript”> function isNumberKey(evt) { var re=new RegExp(/^[0-9]*.?[0-9]*$/); if(document.getElementById(“text”).value.match(re)) { alert(“match”); } else { alert(“no match”); return false; } } </script> </head> <body> <input id=”text” type=”text” value=”0″
Javascript Calendar Problem on Chrome and Safari browsers
While working in a project, we faced a problem with using a calendar on a webpage. It was working fine for Mozilla Firefox but not for Chrome and Safari. Initially we had this code: <input type=”text” name=”startdate” id=”startdate” class=”form-control datepicker”
Java | Maven | How to pack Maven dependencies while creating jar file
We were creating a Maven project having packaging type jar. We had main class from where we were starting project execution. It was working fine through Eclipse but when we created jar file by compiling with Maven, we were not