A blog containing Salesforce coding examples in detail.It's a place where you can find solutions to the problems that you may face in your daily salesforce coding. Apex classes,visual force page,we services,Integration,plugins,extensions,Lightning web components,Aura components,Email Messages,Sales cloud,service Cloud,Marketing Cloud. Amazon Affliate Link: https://amzn.to/43zNb70
Thursday, July 31, 2014
Friday, July 11, 2014
How Can I Become A MVP (Force.com)
At First I would like to thank Ankit Arora,for sharing very useful information on "How Can I Become A MVP (Force.com) " on his blog.
I am sharing a link to that so that all of my friends will go through that link and gain some knowledge.
http://forceguru.blogspot.in/2013/04/how-can-i-become-mvp-forcecom.html
Wednesday, July 9, 2014
System.TypeException: Invalid date: 1/1/2014 error issue
System.TypeException: Invalid date: 1/1/2014 error issue
whenever we are assaigning a string which contains date to date field ,we get this error because of different date format.So to resolve this issue we need to change date format.
For example I got this error "System.TypeException: Invalid date: 1/1/2014"
I resolved this issue in the following way..
string DateScheduled='1/1/2014';
String[] myDateOnly = DateScheduled.split(' ');
String[] strDate = myDateOnly[0].split('/');
Integer myIntDate = integer.valueOf(strDate[1]);
Integer myIntMonth = integer.valueOf(strDate[0]);
Integer myIntYear = integer.valueOf(strDate[2]);
account.DateScheduled__c=Date.newInstance(myIntYear, myIntMonth, myIntDate);
Here DateScheduled__c is a custom date field in account object.
Hope this helps you...
whenever we are assaigning a string which contains date to date field ,we get this error because of different date format.So to resolve this issue we need to change date format.
For example I got this error "System.TypeException: Invalid date: 1/1/2014"
I resolved this issue in the following way..
string DateScheduled='1/1/2014';
String[] myDateOnly = DateScheduled.split(' ');
String[] strDate = myDateOnly[0].split('/');
Integer myIntDate = integer.valueOf(strDate[1]);
Integer myIntMonth = integer.valueOf(strDate[0]);
Integer myIntYear = integer.valueOf(strDate[2]);
account.DateScheduled__c=Date.newInstance(myIntYear, myIntMonth, myIntDate);
Here DateScheduled__c is a custom date field in account object.
Hope this helps you...
Convert string to date in apex
In order to convert string value to date,use valueOf().
For Example
String datevalue = '1/2/2014';
Date d = Date.valueOf(datevalue );
For Example
String datevalue = '1/2/2014';
Date d = Date.valueOf(datevalue );
Subscribe to:
Comments (Atom)
-
How to retrieve validation rules using package.xml in vs code salesforce - Salesforce Globe For You Problem : Assume a validation Mobile_...
-
Generally we get this error when we are not doing type casting properly. Recently I got this error when I am saving the below apex class. ...
<style>
.rowColor {
background-color:orange;
}
</style>
<script>
var pRow='';
function highlightElem(a) {
var c=a.className;
// alert(c);
a.className="rowColor";
if(pRow==''){
pRow=a;
}
else {
if(pRow.innerHTML!=a.innerHTML) {
pRow.className=c;
pRow=a;
}
}
}
</script>
<apex:form >
<apex:pageBlock >
<apex:PageBlockTable value="{!accounts}" var="r" onRowClick="highlightElem(this)" >
<apex:column value="{!r.Name}" />
<apex:column value="{!r.Phone}" />
<apex:column value="{!r.Type}" />
</apex:PageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>