Tuesday, February 5, 2013

Campaign New Button Not Visible In apex salesforce


Check you user detail marketing user check box must be clicked.
Setup -> Personal Setup -> Personal Information -> Marketing user 




Thanks
Vijay




Thursday, June 7, 2012

Multiple address on Visualforce Page with GMAP in apex salesforce

Hi guys ,

Look at standard visualforce page for showing multiple address on Gmap.

<apex:page standardController="Account" sidebar="false">
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA&sensor=false" type="text/javascript"></script>
<script type="text/javascript">
            var map = null;
            var geocoder = null;          
            function initialize() {
                if (GBrowserIsCompatible()) {
                    map = new GMap2(document.getElementById("map_canvas"));
                    map.setCenter(new GLatLng(24.957639, 46.698775), 4);
                    geocoder = new GClientGeocoder();
                    map.setUIToDefault();                  
                }
            }

            function createMarker(point,address)
            {   
                // Create our "tiny" marker icon
                var blueIcon = new GIcon(G_DEFAULT_ICON);
                blueIcon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/green/blank.png";
                blueIcon.iconSize = new GSize(32, 32)
                // Set up our GMarkerOptions object
                markerOptions = { icon:blueIcon };
                var marker = new GMarker(point, markerOptions);
                GEvent.addListener(marker, "click", function() {
                    marker.openInfoWindowHtml("<b>"+address+"</b>");
                });
                return marker;
            }
            function showAddress()
            {
                var address1='{!Account.BillingCity}'+'|'+'{!Account.ShippingCity}';
                var address=address1.split('|');
                for(var i=0;i<address.length;i++)
                {
                    if(address[i] == ''){continue;}
                    var addPart = address[i];
                    //alert("addM('" + addPart[0] + "','" + addPart[1] + "');");
                    //setTimeout("addM('" + addPart + "');",300);
                    addM(addPart);
                }
            }

            function addM(add)
            {
                add = add + ",India";
                if (geocoder)
                {
                    geocoder.getLatLng(add,function(point)
                        {
                            if (!point)
                            {
                                alert(add + " not found");
                            }
                            else
                            {                             
                                map.addOverlay(createMarker(point,add));                            
                            }
                        }
                    );                  
                }

            }
</script>
      
  <apex:form >   
      <div id="map_canvas" style="width: 989px; height: 250px"></div>
      <input type="button" value = "Show Markers" onClick="showAddress();"/>     
  </apex:form>
  <script type="text/javascript">
      initialize();
  </script>     
</apex:page>

Lets say your page name is multipleAddress your url looks like /apex/multipleAddress?id=accountId
Thanks

Tuesday, May 29, 2012

Calculate Hour Minute In Apex Salesforce

Hi ,

As I had gone to search that how to separate hour and minute in apex , I was trying to search any method which could be return after decimal value so that I could calculate all values after decimal place as total number of minute and then extract the hour from total number of minute divide by 60 and separate again hour and minute !

Then I wrote some logic which is explained below !

We have a class contains two methods returnCheckDecimalValueForMin(string val) and returnCheckDecimalValueForHour(string hour) .

public class className {
public string returnCheckDecimalValueForMin(string dayVal){                      
                string[] ss = new string[]{};
                if(dayVal !='' && dayVal!=null){
                        if(dayVal.contains('.')){                         
                         string sss = dayVal.replace('.',',');
                         ss = sss.split(',');              
                         return ss[1] ;                                         
                        }else {
                                return dayVal ;
                        }
                        if(ss.size()>0){
                                return ss[1];
                        }else {return '';}
                }else { return '';}                                           
        }
       
        public string returnCheckDecimalValueForHour(string dayVal){
                string[] ss = new string[]{};
                if(dayVal !='' && dayVal!=null){
                        if(dayVal.contains('.')){                         
                         string sss = dayVal.replace('.',',');
                         ss = sss.split(',');           
                         return ss[0] ;                                                   
                        }else {                                
                                return dayVal ;
                        }                      
                }else { return '';}                                    
        }
}

Now let say we have a list of decimal values like 34.46 , 34.56 , 45.57

so what we need to do actually to separate
34+34+45 =   113

46+56+67 =  169

integer i = math.mod(169,60);

integer returnHr = 169/60 ;

Integer TotalHours = 113 + returnHr.intvalue();

Integer remainingMinutes = 169 - 60*returnHr.intvalue() ;                                                                                                                                  

Friday, May 25, 2012

User Photo Not Visible On Force.com Site From Rest API In Apex Salesforce


Hi All ,
I was accessing the photourl through force.com site !

"photo": {
        "largePhotoUrl": "https://instance_name/profilephoto/729D00000000BDV/F",
        "photoVersionId": "729D00000000BDV",
        "smallPhotoUrl": "https://instance_name/profilephoto/729D00000000BDV/T"
},

Now if we expose these photo url on visualforce page would render properly but if we try to get the same of public force.com site these photo url does not exist because session does not maintain .Images look like burst and does not show properly.

So what we can do , we can append either oauth_token or sessionid at the last of the photourl as a parameter. 
Let say our photo url is "largePhotoUrl": 

"https://instance_name/profilephoto/729D00000000BDV/F",

so we need to append the oauth_token like :



largePhotoUrl": "https://instance_name/profilephoto/729D00000000BDV/F'?oauth_token=00DV0000004RJpB!ARMAQFwrXxu7t6DAjWcseeWxXTo9UtSh4xZbrWJqHRnCulQ16yKqq97wIWIREdPtKfQ7BcFffyD9Y43MVBfa4hmHaPLfkT6C';
Now you can access the image as public with the help of oauth_token . Thanks





Wednesday, May 23, 2012

Product And Campaign Tab Not Visible For Partner Portal Tab In apex Salesforce

Hi ,
Very first think you need to check that Customize Portal Tab for partner portal if any of the tab is not available in the left or right drop down then its mean those tabs are not available for portal user .

We have alternate option to do the same that we can create a simple VF page with the standard controller of that particular object and redirected page url to the url comes when clicking on product or Campaign Tab generally .

Below is example for product tab :

VF Page :

<apex:page standardController="Product2" extensions="ProductTabCls" action="{!ProductRrl}">


</apex:page>

Class Code :

public class ProductTabCls {

    public ProductTabCls(ApexPages.StandardController controller) {

    }   

    public pagereference ProductRrl(){

        pagereference page = new pagereference('/01t/o');

        page.setRedirect(true);

        return page;

    }   

}


Now Create a Visualforce Tab by selecting the newly created VF page !

Campaign Tab New Button Not Visible For Some Users In Apex Salesforce

Hi All ,

Campaign is only available for marketing users . If you have marketing user licence you can enable to User to create a campaign .
You just need to checked Marketing User Check box on User Personal Information .
 Setup->  My Personal Information - > Personal Information --> Edit
 Checked Marketing User Check box  click save !


Thursday, March 29, 2012

Export Excel if(!window.sfdcPage){ window.sfdcPage = new ApexPage(); } Issue with MAC in apex visualforce

Hi guys ,
I faced a big issue with MAC if I am exporting .xls file through visualforce page.
The problem arise only in case if we are using PageBlock and PageBlock Table . I just replaced pageBlockTable with simple datatable and problem resolved.

Thanks