Play Games

Search This Blog

Thursday, July 31, 2014

How to change background colour of a selected row of a page block table?


<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
    <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>

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...

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 );