• Kanagaraj Arjunan 11
  • 10 Points
  • Member since 2015

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
  • 1
Hi All
I am trying to decrypt an attachment. while when i excecute the code i am receiving the error like "Input length must be multiple of 16 when decrypting with padded cipher in salesforce" below is my code.

global with sharing class decryptAttachment {
    webservice static string decryptAttachmentfile(Id caseIds) {
        c Document d = new Document();
        d.FolderId = UserInfo.getUserId();
        Attachment a = [SELECT Id, Name,ParentId,Body,ContentType FROM Attachment WHERE ParentId =:caseparentIds];
        d.ContentType = a.contentType;
        EncryptionKey__c keySetting = EncryptionKey__c.getOrgDefaults();
        Blob aesKey = EncodingUtil.base64Decode(keySetting.aeskey__c);
        d.Body = Crypto.decryptWithManagedIV('AES256', aesKey, a.Body);
        d.Name = a.Name;
        insert d;
        return d.id;
Hi All

I am trying to decrypt an attachment. while when i excecute the code i am receiving the error like "Input length must be multiple of 16 when decrypting with padded cipher in salesforce" below is my code.

global with sharing class decryptAttachment {
    webservice static string decryptAttachmentfile(Id caseIds) {
        c Document d = new Document();
        d.FolderId = UserInfo.getUserId();
        Attachment a = [SELECT Id, Name,ParentId,Body,ContentType FROM Attachment WHERE ParentId =:caseparentIds];
        d.ContentType = a.contentType;
        EncryptionKey__c keySetting = EncryptionKey__c.getOrgDefaults();
        Blob aesKey = EncodingUtil.base64Decode(keySetting.aeskey__c);
        d.Body = Crypto.decryptWithManagedIV('AES256', aesKey, a.Body);
        d.Name = a.Name;
        insert d;
        return d.id;
Hi All
We have enable Platform encryption in our organizations. It works with standard and the custom  fields. While coming to encrypting the files and attachment, files are displaying content even they are encrypted. How to encrypt the files using Platform Encryption
I am retrieving a list of geo coords via JSON and popping them onto a google map. All is working well except in the instance when I have two or more markers on the exact same spot. The API only displays 1 marker - the top one.
Hi All

I have develop a google map to show the location for more than 100 records. But now the problem is when the page is loading map is not display can you please anyone help to me to resolve this problem.

This my page
<apex:page sidebar="false" controller="MapController1">
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var markers = JSON.parse('{!jsonString}');

window.onload = function () {

    var mapOptions = {
        center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
        zoom: 8,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    var infoWindow = new google.maps.InfoWindow();
    var latlngbounds = new google.maps.LatLngBounds();
    var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
    var i = 0;
    var interval = setInterval(function () {
        var data = markers[i]
        var myLatlng = new google.maps.LatLng(data.lat, data.lng);
        var icon = "";
        switch (data.type) {
            case "Hospital":
                icon = "red";
            case "Beach":
                icon = "blue";
            case "Mall":
                icon = "yellow";
            case "Park":
                icon = "green";
        icon = "https://maps.google.com/mapfiles/ms/icons/"+icon+".png";
        var marker = new google.maps.Marker({
            position: myLatlng,
            map: map,
            title: data.title,
            animation: google.maps.Animation.DROP,
            icon: new google.maps.MarkerImage(icon)
        (function (marker, data) {
            google.maps.event.addListener(marker, "click", function (e) {
                    infoWindow.open(map, marker);
        })(marker, data);
        if (i == markers.length) {
            var bounds = new google.maps.LatLngBounds();
    }, 80);
    <td valign="top">
        <u>Legend:</u><br /><br /><br />
        <img alt="" src="https://maps.google.com/mapfiles/ms/icons/red.png" />
        Hospitals<br />
        <img alt="" src="https://maps.google.com/mapfiles/ms/icons/blue.png" />
        Beaches<br />
        <img alt="" src="https://maps.google.com/mapfiles/ms/icons/yellow.png" />
        Malls<br />
        <img alt="" src="https://maps.google.com/mapfiles/ms/icons/green.png" />
        Parks<br />
        <div id="dvMap" style="width: 1200px; height: 555px">

This my controller

public class MapController1 {

  List<Account> AccountList;
  List<mapWrapper> mapWrapperList;
  public String jsonString{get;set;}
  public MapController1(){
  mapWrapperList = new List<mapWrapper>();
  for(Asset mw : [SELECT Name,Geolocation__Latitude__s,Geolocation__Longitude__s,type__c,Account_Address__c,Account.Name,AccountId,Service_Contract_Provider__c,Product2Id,Product2.Name,Product_Description__c,Lease_Start_Date__c,Actual_End_Date__c,Status from Asset where (Lease_Start_Date__c <=: System.Today() AND  Actual_End_Date__c >=: System.today()) AND (Status ='Active Lease' OR Status= 'Future Lease')
                    And Geolocation__Latitude__s != null and  Geolocation__Longitude__s != null AND type__c !=null AND Account.Name != null  AND Service_Contract_Provider__c != null AND Account_Address__c != null AND type__c != null AND product2.Name != null AND Name != null]){
 mapWrapper mwrap = new mapWrapper();

 mwrap.title = mw.Name;
 mwrap.accountName = mw.Account.Name;
 mwrap.lat = String.valueOf(mw.Geolocation__Latitude__s);
 mwrap.lng = String.valueOf(mw.Geolocation__Longitude__s);
 mwrap.description = mw.Service_Contract_Provider__c;
 mwrap.productName  = mw.Product2.Name;
 mwrap.type = mw.type__C;
 mwrap.accountAddress = mw.Account_Address__c;

   jsonString = json.serialize(mapWrapperList);
  public class mapWrapper{
  public String title{get;set;}
  public String accountName{get;set;}
  public String productName{get;set;}
  public String lat{get;set;}
  public String lng{get;set;}
  public String type{get;set;}
  public String description{get;set;}
  public String accountAddress{get;set;}


Hi All

When i save the Apex class it shows error like " expecting right square bracket, found 'OR' " in below i have given the soql query. if anyone konw about this issue please help me.

List<Asset> Assestobj = [SELECTName,Account_Address__c,Account.Name,AccountId,Service_Contract_Provider__c,Product2Id,Product2.Name,Product_Description__c,Lease_Start_Date__c,Actual_End_Date__c,Status from Asset where Lease_Start_Date__c <=: date.today().format() AND  Actual_End_Date__c >=: date.today().format() AND Status ='Active Lease' OR Status= 'Future Lease'];
Hi All

I have created a google map to display more than 100 Account address in a visualforce page. But the problem is when i  tab it display blank page. Can anyone help me to reslove this issue. What i did a mistake here?

This is My Controller

public class AssetMapController
public List<Account> AllAddreess {get;set;}
public AssetMapController()

AllAddreess = [select id,Name,BillingStreet,BillingCity,BillingState,BillingCountry from Account];

This my Visualforce Page

 <apex:page controller = "AssetMapController" sidebar = "false">
 <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
        #map {
            font-family: Arial;
            line-height:normal !important;
            padding: 20px;
            /* outer shadows  (note the rgba is red, green, blue, alpha) */
            -webkit-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.4); 
            -moz-box-shadow: 0px 1px 6px rgba(23, 69, 88, .5);
            /* rounded corners */
            -webkit-border-radius: 12px;
            -moz-border-radius: 7px; 
            border-radius: 7px;
            /* gradients */
            background: -webkit-gradient(linear, left top, left bottom, 
            color-stop(0%, white), color-stop(15%, white), color-stop(100%, #D7E9F5)); 
            background: -moz-linear-gradient(top, white 0%, white 55%, #D5E4F3 130%); 
    <script type="text/javascript">                   
        var geocoder;
        var map;
        var infowindow = new google.maps.InfoWindow();
        var places = [];
        var title_content = new Array();                    
        var popup_content = new Array();                    
        var address = new Array();
        var address_position = 0;                    
        var timeout = 600;
        function initialize(){
            geocoder = new google.maps.Geocoder();
            var latlng = new google.maps.LatLng(29.01, 77.38);
            var myOptions = {
              zoom: 2,
              center: latlng,
              mapTypeId: 'roadmap'
            <apex:repeat value="{!AllAddreess}" var="loc" >
                title_content.push("Name: "+"{!loc.Name}"+" \nClick for more Detail");                 
                address.push("{!loc.BillingStreet}, {!loc.BillingCity}, 
                popup_content.push("<b>Account Name: {!loc.Name}
                +"<br/>Street: {!loc.BillingStreet}"
                +"<br/>City: {!loc.BillingCity}<br/>Postal State: {!loc.BillingState}"+
                +"<br/>Country: {!loc.BillingCountry }</b>");                                                    
            map = new google.maps.Map(document.getElementById("map"), myOptions);
        function addMarker(position){
            geocoder.geocode({'address': address[position]}, function(results, status){
                if (status == google.maps.GeocoderStatus.OK) {
                    places[position] = results[0].geometry.location;                                    
                    var marker = new google.maps.Marker({
                        position: places[position],
                        icon: marker.setIcon('nostarch-logo.png', [27,31]);
                        map: map
                    google.maps.event.addListener(marker, 'click', function() {
                        if (!infowindow) {
                            infowindow = new google.maps.InfoWindow();
                        infowindow.open(map, marker);
                    if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT){
                        setTimeout(function() { addMarker(position); }, (timeout * 3));
                if (address_position < address.length){
                    setTimeout(function() { addMarker(address_position); }, (timeout));
            @Description: To Put diffren color image on Google Map
            @Param: Marker Number to Add on map.
        function getMapIconUrl(){
            var mapIconUrl = "{!$Resource.GoogleMarker}";
            return mapIconUrl;
    <apex:pageMessages />
    <div id="map" class="roundCornerCss"></div>   
Hi All

How to create a google map for more than 100 records. my requirement is when i click the tab  then it display the map for 100 or more than  100 accounts address 
Hi All 

I am trying to write test class for the below class but i couldn't achive this. Anyone have idea about it please explain me .

public class JSON2Apex {

    public class Address_components {
        public String long_name;
        public String short_name;
        public List<String> types;

    public class Northeast {
        public Double lat;
        public Double lng;

    public List<Results> results;
    public String status;

    public class Bounds {
        public Northeast northeast;
        public Northeast southwest;

    public class Geometry {
        public Bounds bounds;
        public Northeast location;
        public String location_type;
        public Bounds viewport;

    public class Results {
        public List<Address_components> address_components;
        public String formatted_address;
        public Geometry geometry;
        public Boolean partial_match;
        public String place_id;
        public List<String> types;
Hi All

How to create a google map for more than 100 records. my requirement is when i click the tab  then it display the map for 100 or more than  100 accounts address