• B
  • NEWBIE
  • 150 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 33
    Replies
I want to replace an URL hack. I found that one of the option is to use a flow.

The button need to bypas which type of solution do you want to choose.
This is the url: 
'/a0A/e?CF00ND0000005pODo={!opp.Name}&CF00ND0000005pODo_lkid={!opp.Id}&retURL=%2F{!opp.Id}&RecordType=012D00000007LTY&Opportunity__c={!opp.Name}&Solution_Country__c={!acc.Country__c}&ent=01ID0000000uXce';

I know how to use flow in order to get the  information from oppportunity and account but not how to oppen that specific record type and entitiy from flow.

Any ideas how to solve this ? 



 
  • July 10, 2019
  • Like
  • 0
I want to go straight to a solution record type without being need to select the record type. When i check the url i see that opp name it is different than the one from where i started the solution.

Here is my visualforcepage
<apex:page standardController="Solutions__c" recordSetVar="solutions" extensions="SolutionWrapper" >
        
        <script>        
            function redirect(){
                window.location.href='/a0A/e?CF00ND0000005pODo={!opp.Name}&CF00ND0000005pODo_lkid={!opp.Id}&retURL=%2F{!opp.Id}&RecordType=012D00000007LTY&Opportunity__c={!opp.Name}&Solution_Country__c={!sol.Solution_Country__c}={!acc.Country__c}&ent=01ID0000000uXce';
            }
            window.onload = window.setTimeout(redirect(),5000);
        </script>

</apex:page>

Controller :

public with sharing class SolutionWrapper {
    public Opportunity opp{get; set;}
    public Solutions__c oppId{get; set;}
    public Solutions__c sol{get; set;}
    public Solutions__c solution{get; set;}
    public Account acc{get; set;}
  
    public SolutionWrapper(ApexPages.StandardSetController controller) {
        try{
            solution = new Solutions__c();
            solution = (Solutions__c)controller.getRecord();
            if(solution.Id != null){
                oppId = [SELECT id, Solutions__c.Opportunity__c,Mail_Merge_Id__c
                    FROM Solutions__c
                WHERE id =: solution.id
                OR Mail_Merge_Id__c =: solution.Mail_Merge_Id__c 
                LIMIT 1];
                
                opp = [Select id,Name, AccountId, CurrencyIsoCode  from 
                         Opportunity where id =: oppId.Opportunity__c  LIMIT: 1];
            }
            
            if(opp.id !=null){
                sol = [SELECT id,Name, Mail_Merge_Id__c,Solution_Country__c, Solutions__c.Opportunity__c 
            FROM Solutions__c
            WHERE Solutions__c.Opportunity__c =: opp.id
            LIMIT 1];
                 acc = [Select id,Name,Country__c from 
                         Account where id=:opp.AccountId LIMIT: 1];
            }
            
            
        }
        catch(Exception e){
            ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR,e.getMessage()));
        }

    }

}
  • June 19, 2019
  • Like
  • 0
I  try to create  a flow in lightning. I have my account record that has multiple fields. In the first screen i want to display ony the fields(20 fields) that are not empty. The problem is that i can not really use decision because i will end up with a big tree and i think is not such a good practice.

 
  • May 29, 2019
  • Like
  • 0
User-added image
As an admin i want to not let users to modify how the kanban view is displayed. I want to set up the summarize and group by and users to not be able to change it . Basically i think it they should not be able to click on kanban settings at all. It is possible to do that ? 
  • May 22, 2019
  • Like
  • 0
Hi,

If i have an apex class that has API version 29 and now i change  it to 45 for example, it will be somehow affected  the funtioning of the apex class, teoretically speaking.

Thanks in advance
  • May 21, 2019
  • Like
  • 0
I only found this reference on the internet which is saying that is available on mobile (true) and they are going to implement this on web too(it passed 4 years)
https://success.salesforce.com/ideaView?id=08730000000l6aHAAQ&

Are any updates on this ? 
  • May 14, 2019
  • Like
  • 0
I have this code: 


JS controller: 
var map = L.map('map', {zoomControl: true, tap: false, preferCanvas:true})
 var group1,group2,group3,group4;
 var myRenderer = L.canvas({ padding: 0.5 });
 var markers = L.markerClusterGroup.layerSupport( { 
            chunkedLoading: true,
            renderer: myRenderer,
            iconCreateFunction: function  (cluster) {
            var childCount = cluster.getChildCount();
              
            var c = ' marker-cluster-';
            if (childCount < 10) {
                c += 'small';
            } 
            else if (childCount < 100) {
                c += 'medium';
            } 
            else {
                    c += 'large';
            }
            
            return new L.DivIcon({ html: '<div><span>' + childCount + '</span></div>', 
                                  className: 'marker-cluster' + c, iconSize: new L.Point(40, 40) });
             }
 });

 group1 = L.layerGroup(),
           group2 = L.layerGroup(),
          group3 = L.layerGroup(),
           group4 = L.layerGroup(),
        
        markers.checkIn([group1, group2, group3, group4]);
       
        var overlayMaps = {
            "g1": group1,
            "g2": group2,
            "g3":group3,
            "g4":group4
        };
        var control = L.control.layers(null, overlayMaps, { collapsed: true });
        /*control.addOverlay(group1, 'g1');
        control.addOverlay(group3, 'g3');
        control.addOverlay(group2, 'g2);
        control.addOverlay(group4, 'g4'); */
        
         //controlMarkers = L.control.layers(markers, null, { collapsed: true });
         //controlHeatMap = L.control.layers(heatmapLayer, null, { collapsed: true });
        
        control.addTo(map);

        group1.addTo(map); // Adding to map or to AutoMCG are now equivalent.
        group2.addTo(map);
        group3.addTo(map);
        group4.addTo(map);

 markers.addTo(map);

The prolem is that when i check out  on overlay and after i check in again  i receive this error: 

Uncaught TypeError: Cannot read property 'x' of undefined
throws at dist/leaflet.markercluster.js:1:25696 TypeError: Cannot read property 'x' of undefined
    at L.DistanceGrid._sqDist (DistanceGrid.js:114)
    at L.DistanceGrid.getNearObject (DistanceGrid.js:94)
    at e._addLayer (MarkerClusterGroup.js:974)
    at eval (MarkerClusterGroup.js:249)
    at e.addLayers (MarkerClusterGroup.js:283)
    at e.addLayers (layersupport.js:99)
    at e.onAdd (layersupport.js:517)
    at e._layerAdd (leaflet.js:5)
    at e.whenReady (leaflet.js:5)
    at e.addLayer (leaflet.js:5)

I saw that this function is called  from DistanceGrid 

_sqDist: function (p, p2) {
        var dx = p2.x - p.x,
            dy = p2.y - p.y;
        return dx * dx + dy * dy;
    }

And when i checked in is p  is somehow undefined. Im struggling with this error for a long period already. Maybe you have some suggestion

libraries that are imported 
/resource/leaflet/leaflet.js,
/resource/leafletMarkerCluster/Leaflet.markercluster-1.4.1/dist/leaflet.markercluster.js,                 /resource/LeafletFilterCluster/Leaflet.MarkerCluster.LayerSupport-master/src/layersupport.js
 
  • April 22, 2019
  • Like
  • 0
Here  is my aura component , suddently it didnt want to display nothing more that the button and selector and i dont understand why. Basically the things  that are not displayed are the map and the list. THis behaviour is only on mobile app  , on desktop is working just fine.


<aura:component >
    <aura:attribute name="map" type="Object"/>
    <aura:attribute name="markers" type="Object"/>

    <ltng:require styles='/resource/leafletMarkerCluster/Leaflet.markercluster-1.4.1/dist/MarkerCluster.css, 
/resource/leafletMarkerCluster/Leaflet.markercluster-1.4.1/dist/MarkerCluster.Default.css,
/resource/leaflet/leaflet.css,
/resource/leafletSearch/leafletSearch/leafletSearch/dist/leaflet-search.min.css'
                  
                  scripts='/resource/leaflet/leaflet.js,/resource/leafletMarkerCluster/Leaflet.markercluster-1.4.1/dist/leaflet.markercluster.js,                        /resource/leafletSearch/leafletSearch/leafletSearch/src/leaflet-search.js,                    /resource/LeafletFilterCluster/Leaflet.MarkerCluster.LayerSupport-master/src/layersupport.js,
 /resource/LeafletLocateControl/leaflet-locatecontrol-gh-pages/dist/L.Control.Locate.min.js'
                           
                  afterScriptsLoaded="{!c.jsLoaded}" />
    
    <div aura:id= "screen">
          
        <div id="map" aura:id="mapSize" class="mapSize" style="position:relative;">   

         
        <div id = "select"  >
            <c:Selector/>
        </div>
        <div id="listControl" >
            <lightning:button class="button" aura:id="buttonList" label="Button" onclick="{!c.click}" />
        </div>

    </div>
       <div  aura:id="listDiv" class ="listDiv">
    <aura:if isTrue="{!v.map}"> 
       <c:AccountList aura:id="list" /> 
    </aura:if>
    </div>       
        </div>
</aura:component>
  • April 11, 2019
  • Like
  • 0
I used this 

 var markers = L.markerClusterGroup.layerSupport( { 
            chunkedLoading: true,
            renderer: myRenderer,
            iconCreateFunction: function  (cluster) {
            var childCount = cluster.getChildCount();
              
            var c = ' marker-cluster-';
            if (childCount < 10) {
                c += 'small';
            } 
            else if (childCount < 100) {
                c += 'medium';
            } 
                else {
                    c += 'large';
                }
            
            return new L.DivIcon({ html: '<div><span>' + childCount + '</span></div>', 
                                  className: 'marker-cluster' + c, iconSize: new L.Point(40, 40) });
             }
        }),
            group1 = L.layerGroup(),
              group2 = L.layerGroup(),
             group3 = L.layerGroup(),
              group4 = L.layerGroup(),
             
            control = L.control.layers(null, null, { collapsed: true }),
             
            groupActive = L.layerGroup(),
              groupInactive = L.layerGroup(),
             
            controlStatus = L.control.layers(null, null, { collapsed: true });


markers.checkIn([group1, group2, group3, group4]);

        control.addOverlay(group1, 'apples');
        control.addOverlay(group3, 'bananas');
        control.addOverlay(group2, 'cars');
        control.addOverlay(group4, 'windows');


which is good but not good enough , i need to be able to filter dinamically based on  text input because if i use groups i will end up with 40 groups which is not good
  • April 08, 2019
  • Like
  • 0
So i call the controller from vf page and the pdf si saved as a file but i dont know how to link it to opportunity 

 PageReference pdf = Page.CreatePDF;
    pdf.getParameters().put('id',opp.Id);
   
    Blob body;
    
    try {
        
        body = pdf.getContent();
        
    } catch (VisualforceException e) {
        body = Blob.valueOf('Error');
    }
 
    ContentVersion cont = new ContentVersion();
    cont.Title = 'lala' +acc.Name + '-' + opp.Number__c + '.pdf';
    cont.PathOnClient = 'lala.pdf';   //The complete path of the document. One of the fields that determines the FileType.
    cont.VersionData = body; // The content or body of the note, which can include properly formatted HTML or plain text. 
    cont.Origin = 'C'; 
    insert cont;    

I dont want it as as attachment
  • April 03, 2019
  • Like
  • 0
This is the error 
Geocoding Service: You have exceeded your daily request quota for
I know about the limitations, what i need is a solution to the problem

This is the code 

<apex:page standardController="Account" recordSetVar="accounts" >
<apex:pageBlock >
<head>

    <script type="text/javascript" src="https://maps.google.com/maps/api/js?key=xxxixixixixixixixixixixi"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">

$(document).ready(function() {

  var myOptions = {
    zoom: 20,
    mapTypeId: google.maps.MapTypeId.HYBRID,
    mapTypeControl: true
  }

  var map;
  var marker;
    
  var geocoder = new google.maps.Geocoder();
  var address = new Array();
    <apex:repeat value="{!accounts}" var="addresss">
        if("{!addresss.BillingCountry}" != ""){
        address.push("{!addresss.BillingCountry}");

        }
    </apex:repeat>  
      
  var infowindow = new google.maps.InfoWindow({
    content: ""
  });
 for (var x = 0; x < address.length; x++) {
  console.log();
 console.log(address[x]);
  geocoder.geocode( { address: address[x]}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {

        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);

        //center map results[0].geometry.location
          // map.setCenter(geoSuccess);

        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Account.Name}"
        });

        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition()); 
        });
          
        

      }

    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Name}'s address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  })};

  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }

});
            </script>
            <style>
            #map {
                      font-family: Arial;
                      font-size:12px;
                      line-height:normal !important;
                      height:500px;
                      background:transparent;
            }
            </style>
        </head>
            <body>
                <div id="map"></div>
            </body>
    </apex:pageBlock>
</apex:page>


How to center the map after, on your current location that will be helpfull 
  • April 02, 2019
  • Like
  • 0
Here is my vf 

<apex:page standardController="Opportunity" standardStylesheets="false" applyHtmlTag="false" showHeader="false" renderAs="PDF">

    <head>
     ...style..    
   </head>
<body>
   .... information generated based on the opportunity fields..
</body>
</apex:page>

The vf is linked to a detailed buton.
When i click  the button  it opens vf page but in the same time i want to be saved as an attachment/file in the opportunity  

Any suggested implementations ? 
 
  • April 01, 2019
  • Like
  • 0
I want to display around 40k markers on the map. I tried like this but maximum is 10 (i read in documentation this is some sort of a limitation).

Here is my code: 
<apex:page standardController="Account" recordSetVar="accounts" >

  <apex:map width="1200px" height="1000px" mapType="roadmap"
    center="42.23  42.23">
        <apex:repeat value="{! accounts }" var="acc">
        <apex:mapMarker title="{! acc.Name }" position="{!acc.BillingLatitude}, {!acc.BillingLongitude},{!acc.BillingCity}, {!acc.Billing_Zip_Postal_Code__c}" />
        </apex:repeat>
  </apex:map>
  </apex:page>

Is there any posibility to do that ? 
  • March 28, 2019
  • Like
  • 1
I try to convert the javascript buttons in order to make them work in lightning.

Visualforcepage: 

<apex:page standardController="Solutions__c" recordSetVar="solutions" extensions="SolutionWrapper" >

      <script>

            function redirect(){
                alert('{!sol.Solution_Country__c}');
                window.location.href='/a0A/e?xxxxxxx={!opp.Name}&xxxxxxx={!opp.Id}&retURL=%2F{!opp.Id}&RecordType=xxxxx&Solution_Country__c={!sol.Country}={!acc.Country__c}&ent=xxxxxxx';
            }
            window.onload = window.setTimeout(redirect(),5000);
        </script>
</apex:page>

This visual force page is integrated in a 'Custom Button or Link Edit' because in my case i can not use action.

Given the fact that url hack are not working anymore in lightning , are there any other way in this case to prepopulate the fields of the url destination. 

Thanky you in advance 
  • March 21, 2019
  • Like
  • 0
Here is what i tried
apex class:
public with sharing class SolutionWrapper {
    public ApexPages.StandardSetController controller;
    public Opportunity opp{get; set;}
    public Solutions__c oppId{get; set;}
    public Solutions__c sol{get; set;}
    public Solutions__c solution{get; set;}
    public Account acc{get; set;}
  
    public SolutionWrapper(ApexPages.StandardSetController controller) {
        try{
            solution = new Solutions__c();
            solution = (Solutions__c)controller.getRecord();
            if(solution.Id != null){
                oppId = [SELECT id, Solutions__c.Opportunity__c 
                    FROM Solutions__c
                WHERE id =: solution.Id
                LIMIT 1];
                
                opp = [Select id,Name, AccountId, CurrencyIsoCode  from 
                         Opportunity where id =: oppId.Opportunity__c  LIMIT: 1];
            }
            
            if(opp.id !=null){
                sol = [SELECT id,Name, Mail_Merge_Id__c,Solution_Country__c, Solutions__c.Opportunity__c 
            FROM Solutions__c
            WHERE Solutions__c.Opportunity__c =: opp.id
            LIMIT 1];
                 acc = [Select id,Name,Country__c from 
                         Account where id=:opp.AccountId LIMIT: 1];
            }
            
            
        }
        catch(Exception e){
            ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR,e.getMessage()));
        }

    }

}



apex test class:
@isTest 
public class SolutionWrapperTest {

         static testMethod void testMethodOpp(){
             Account acc = new Account(Name='test', Country__c='test'); 
              insert acc; 
             Opportunity opp = new Opportunity(Name='test', AccountId=acc.id, CurrencyIsoCode='GBP', StageName = 'Good',
              CloseDate =  date.today());
             insert opp;
             Solutions__c sol = new Solutions__c( Opportunity__c= opp.id, CurrencyIsoCode='GBP');       
               insert sol;          
             
             List<Solutions__c> listSol = new List<Solutions__c>();
             listSol.add(sol);
             PageReference pageRef = Page.NewVisualForcePage;
             Test.setCurrentPage(pageRef); 
             
            Test.startTest();
             ApexPages.StandardSetController stdController = new ApexPages.StandardSetController(listSol);
             SolutionWrapper testSolution = new SolutionWrapper(stdController);
            Test.stopTest();

            }
        
        
    }
 
  • March 19, 2019
  • Like
  • 0
I  want to use this in other object like oportunity for example

<apex:page standardController="Account" extensions="AccountWrapper" >
  <apex:form >
    <apex:commandbutton value="Button" 
                    onclick="window.location='/a0A/e?asdo={!opp.Name}&asd={!opp.Id}&retURL=%2F{!opp.Id}&
                             RecordType=1234&{!sol.Solution_Country__c}={!Account.Country__c}&
                             CurrencyIsoCode={!opp.CurrencyIsoCode}&ent=01ID0000000uXce'; return false;"/>
    </apex:form>
    
</apex:page>    
 

Is there any solution for that ? I can see it only in account but i want to see it in opportunity or solution etc 
 
  • March 19, 2019
  • Like
  • 0
is working here 
 cancel: function(component, event, helper) {
        $A.get("e.force:closeQuickAction").fire();
    }

but not here  
 save: function(component, event, helper) {
        
        var action = component.get("c.updateAccRecordType");
        action.setParams({
            "accid": component.get("v.recordId")                   
        });
       
        $A.enqueueAction(action);
      $A.get("e.force:closeQuickAction").fire();
          $A.get('e.force:refreshView').fire();
 

       
    },
  • March 12, 2019
  • Like
  • 0
I have this code 

Js controller 

({
    
    init : function(component, event, helper) {
         
        var action = component.get("c.getAcc");
        action.setParams({
            "accid": component.get("v.recordId")                   
        });
        
        action.setCallback(this, function(response) {
            var state = response.getState(); // get the response state
            if (state === "SUCCESS"){
                component.set("v.accountInfo", response.getReturnValue());
                if(component.get("v.accountInfo.Bridger_check__c")=="No Match"){
                          component.set("v.bridge", true);
                        //component.set("v.accountInfo.Bridger_check__c","None");
                 }
            } else if(state === "ERROR"){
                var errors = response.getError();
                let toastParams = {
                    title: "Error",
                    message: "Unknown error", // Default error message
                    type: "error"
                };
                
                // Pass the error message if any
                if (errors && Array.isArray(errors) && errors.length > 0) {
                    toastParams.message = errors[0].message;
                }
                // Fire error toast
                let toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams(toastParams);
                toastEvent.fire();
            }
            
        });
        $A.enqueueAction(action);
    },

        
    handleLoad : function(component, event, helper) {
    component.set("v.showSpinner", false);
     
    },
    handleSubmit : function(component, event, helper) {
       //We don't need to put basic validation here as that are handle by lightning:inputfield and recordEditForm
       
       event.preventDefault(); // stop form submission
       var eventFields = event.getParam("fields");
       eventFields["Bridger_check__c"] = "";
        eventFields["BillingCountry"] = eventFields["Billing_Country__c"];
       component.find('myform').submit(eventFields); 
           
    },
    handleSuccess : function(component, event, helper) {
        
    //Redirect to detail page on success
    var payload = event.getParams().response;
     var navService = component.find("navService");
        var pageReference = {
            type: 'standard__recordPage',
            attributes: {
                "recordId": payload.id,
                "objectApiName": "Account",
                "actionName": "view"
            }
        }
        event.preventDefault();
        navService.navigate(pageReference);
    }
    
 


})

Aura Component 

<aura:component implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" controller="AccountController">
    <aura:attribute name="accountInfo" type="Account"/>
    <aura:attribute name="bridge" type="Boolean"/>
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>
        Account: {!v.accountInfo.Bridger_check__c}
    

        <aura:attribute name="disabled" type="Boolean" default="false" />
    <aura:attribute name="saved" type="Boolean" default="false" />
    <aura:attribute name="showSpinner" type="Boolean" default="true" />
    <lightning:navigation aura:id="navService"/>
    
    <aura:if isTrue="{!v.bridge}">
    <aura:if isTrue="{!v.showSpinner}">
        <lightning:spinner />
    </aura:if>
    <aura:if isTrue="{!!v.saved}">
        <lightning:recordEditForm
            aura:id="myform"
            onload="{!c.handleLoad}"
            onsubmit="{!c.handleSubmit}"
            onsuccess="{!c.handleSuccess}"
            recordId="{!v.recordId}"
            objectApiName="Account">
            <!-- the messages component is for error messages -->
            <lightning:messages />
             Account Information
            <lightning:inputField fieldName="Region__c" />
            <lightning:inputField fieldName="Country__c" />
            <lightning:inputField fieldName="Segment__c" />      
             <lightning:inputField fieldName="Name" /> 
            <lightning:inputField fieldName="Account Site" /> 
        
         
            
            <div class="slds-m-top_medium">
                <lightning:button disabled="{!v.disabled}" variant="brand" type="submit" name="save" label="Save" />
            </div>
        </lightning:recordEditForm>
        <aura:set attribute="else">
            <p>Saved!</p>
        </aura:set>
    </aura:if>
  
    </aura:if>
    
    <aura:if isTrue="{!!v.bridge}">
        "Not good"
    </aura:if>
    
</aura:component>

Apex controller 
@AuraEnabled
  public static Account getAcc(String accid) {
           return [SELECT id,Bridger_check__c
            FROM Account
            WHERE id =: accid
            LIMIT 1];
    }


But after i press save the record type the same. 
Normally if the record is updated then it should change it's record type.

Any ideas ? 
  • March 11, 2019
  • Like
  • 0
I try to get a specified field from the account that im in, but for some reason i can't . Here is my code
Aura comp:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" controller="AccountController">
    <aura:attribute name="account" type="Account[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>
</aura:component>

Js controller 
({
    init : function(component, event, helper) {
        
        var action = component.get("c.getAcc");
        action.setParams({
            "accid": component.get("v.recordId")                    
        }); 
        
         action.setCallback(this, function(a) {
            component.set("v.account", a.getReturnValue());
        });
        $A.enqueueAction(action);

        var test = component.get("v.account");
        alert(test.Bridger_check__c);
       
    }
})

Apex controller 
 @AuraEnabled
    public static List<Account> getAcc(String accid) {
           return [SELECT id,Bridger_check__c
            FROM Account
            WHERE id =: accid 
            LIMIT:1]; 
            
        }

 
  • March 11, 2019
  • Like
  • 0
I try to migrate this but i dont really know how  to do it 

if("{!Account.Bridger_check__c}" == "No"){ 
window.location = "/{!Account.Id}/e?retURL=%2F{!Account.Id}&RecordType=12313123"; 
}else 

alert("no"); 
window.location = "{!Account.Id}"; 
}
I tried to convert it to url but is not good. Any ideas ? 
  • March 08, 2019
  • Like
  • 0
I want to display around 40k markers on the map. I tried like this but maximum is 10 (i read in documentation this is some sort of a limitation).

Here is my code: 
<apex:page standardController="Account" recordSetVar="accounts" >

  <apex:map width="1200px" height="1000px" mapType="roadmap"
    center="42.23  42.23">
        <apex:repeat value="{! accounts }" var="acc">
        <apex:mapMarker title="{! acc.Name }" position="{!acc.BillingLatitude}, {!acc.BillingLongitude},{!acc.BillingCity}, {!acc.Billing_Zip_Postal_Code__c}" />
        </apex:repeat>
  </apex:map>
  </apex:page>

Is there any posibility to do that ? 
  • March 28, 2019
  • Like
  • 1
I want to replace an URL hack. I found that one of the option is to use a flow.

The button need to bypas which type of solution do you want to choose.
This is the url: 
'/a0A/e?CF00ND0000005pODo={!opp.Name}&CF00ND0000005pODo_lkid={!opp.Id}&retURL=%2F{!opp.Id}&RecordType=012D00000007LTY&Opportunity__c={!opp.Name}&Solution_Country__c={!acc.Country__c}&ent=01ID0000000uXce';

I know how to use flow in order to get the  information from oppportunity and account but not how to oppen that specific record type and entitiy from flow.

Any ideas how to solve this ? 



 
  • July 10, 2019
  • Like
  • 0
This is the error 
Geocoding Service: You have exceeded your daily request quota for
I know about the limitations, what i need is a solution to the problem

This is the code 

<apex:page standardController="Account" recordSetVar="accounts" >
<apex:pageBlock >
<head>

    <script type="text/javascript" src="https://maps.google.com/maps/api/js?key=xxxixixixixixixixixixixi"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">

$(document).ready(function() {

  var myOptions = {
    zoom: 20,
    mapTypeId: google.maps.MapTypeId.HYBRID,
    mapTypeControl: true
  }

  var map;
  var marker;
    
  var geocoder = new google.maps.Geocoder();
  var address = new Array();
    <apex:repeat value="{!accounts}" var="addresss">
        if("{!addresss.BillingCountry}" != ""){
        address.push("{!addresss.BillingCountry}");

        }
    </apex:repeat>  
      
  var infowindow = new google.maps.InfoWindow({
    content: ""
  });
 for (var x = 0; x < address.length; x++) {
  console.log();
 console.log(address[x]);
  geocoder.geocode( { address: address[x]}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {

        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);

        //center map results[0].geometry.location
          // map.setCenter(geoSuccess);

        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Account.Name}"
        });

        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition()); 
        });
          
        

      }

    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Name}'s address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  })};

  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }

});
            </script>
            <style>
            #map {
                      font-family: Arial;
                      font-size:12px;
                      line-height:normal !important;
                      height:500px;
                      background:transparent;
            }
            </style>
        </head>
            <body>
                <div id="map"></div>
            </body>
    </apex:pageBlock>
</apex:page>


How to center the map after, on your current location that will be helpfull 
  • April 02, 2019
  • Like
  • 0
Here is my vf 

<apex:page standardController="Opportunity" standardStylesheets="false" applyHtmlTag="false" showHeader="false" renderAs="PDF">

    <head>
     ...style..    
   </head>
<body>
   .... information generated based on the opportunity fields..
</body>
</apex:page>

The vf is linked to a detailed buton.
When i click  the button  it opens vf page but in the same time i want to be saved as an attachment/file in the opportunity  

Any suggested implementations ? 
 
  • April 01, 2019
  • Like
  • 0
I want to display around 40k markers on the map. I tried like this but maximum is 10 (i read in documentation this is some sort of a limitation).

Here is my code: 
<apex:page standardController="Account" recordSetVar="accounts" >

  <apex:map width="1200px" height="1000px" mapType="roadmap"
    center="42.23  42.23">
        <apex:repeat value="{! accounts }" var="acc">
        <apex:mapMarker title="{! acc.Name }" position="{!acc.BillingLatitude}, {!acc.BillingLongitude},{!acc.BillingCity}, {!acc.Billing_Zip_Postal_Code__c}" />
        </apex:repeat>
  </apex:map>
  </apex:page>

Is there any posibility to do that ? 
  • March 28, 2019
  • Like
  • 1
Here is what i tried
apex class:
public with sharing class SolutionWrapper {
    public ApexPages.StandardSetController controller;
    public Opportunity opp{get; set;}
    public Solutions__c oppId{get; set;}
    public Solutions__c sol{get; set;}
    public Solutions__c solution{get; set;}
    public Account acc{get; set;}
  
    public SolutionWrapper(ApexPages.StandardSetController controller) {
        try{
            solution = new Solutions__c();
            solution = (Solutions__c)controller.getRecord();
            if(solution.Id != null){
                oppId = [SELECT id, Solutions__c.Opportunity__c 
                    FROM Solutions__c
                WHERE id =: solution.Id
                LIMIT 1];
                
                opp = [Select id,Name, AccountId, CurrencyIsoCode  from 
                         Opportunity where id =: oppId.Opportunity__c  LIMIT: 1];
            }
            
            if(opp.id !=null){
                sol = [SELECT id,Name, Mail_Merge_Id__c,Solution_Country__c, Solutions__c.Opportunity__c 
            FROM Solutions__c
            WHERE Solutions__c.Opportunity__c =: opp.id
            LIMIT 1];
                 acc = [Select id,Name,Country__c from 
                         Account where id=:opp.AccountId LIMIT: 1];
            }
            
            
        }
        catch(Exception e){
            ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR,e.getMessage()));
        }

    }

}



apex test class:
@isTest 
public class SolutionWrapperTest {

         static testMethod void testMethodOpp(){
             Account acc = new Account(Name='test', Country__c='test'); 
              insert acc; 
             Opportunity opp = new Opportunity(Name='test', AccountId=acc.id, CurrencyIsoCode='GBP', StageName = 'Good',
              CloseDate =  date.today());
             insert opp;
             Solutions__c sol = new Solutions__c( Opportunity__c= opp.id, CurrencyIsoCode='GBP');       
               insert sol;          
             
             List<Solutions__c> listSol = new List<Solutions__c>();
             listSol.add(sol);
             PageReference pageRef = Page.NewVisualForcePage;
             Test.setCurrentPage(pageRef); 
             
            Test.startTest();
             ApexPages.StandardSetController stdController = new ApexPages.StandardSetController(listSol);
             SolutionWrapper testSolution = new SolutionWrapper(stdController);
            Test.stopTest();

            }
        
        
    }
 
  • March 19, 2019
  • Like
  • 0
is working here 
 cancel: function(component, event, helper) {
        $A.get("e.force:closeQuickAction").fire();
    }

but not here  
 save: function(component, event, helper) {
        
        var action = component.get("c.updateAccRecordType");
        action.setParams({
            "accid": component.get("v.recordId")                   
        });
       
        $A.enqueueAction(action);
      $A.get("e.force:closeQuickAction").fire();
          $A.get('e.force:refreshView').fire();
 

       
    },
  • March 12, 2019
  • Like
  • 0
I have this code 

Js controller 

({
    
    init : function(component, event, helper) {
         
        var action = component.get("c.getAcc");
        action.setParams({
            "accid": component.get("v.recordId")                   
        });
        
        action.setCallback(this, function(response) {
            var state = response.getState(); // get the response state
            if (state === "SUCCESS"){
                component.set("v.accountInfo", response.getReturnValue());
                if(component.get("v.accountInfo.Bridger_check__c")=="No Match"){
                          component.set("v.bridge", true);
                        //component.set("v.accountInfo.Bridger_check__c","None");
                 }
            } else if(state === "ERROR"){
                var errors = response.getError();
                let toastParams = {
                    title: "Error",
                    message: "Unknown error", // Default error message
                    type: "error"
                };
                
                // Pass the error message if any
                if (errors && Array.isArray(errors) && errors.length > 0) {
                    toastParams.message = errors[0].message;
                }
                // Fire error toast
                let toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams(toastParams);
                toastEvent.fire();
            }
            
        });
        $A.enqueueAction(action);
    },

        
    handleLoad : function(component, event, helper) {
    component.set("v.showSpinner", false);
     
    },
    handleSubmit : function(component, event, helper) {
       //We don't need to put basic validation here as that are handle by lightning:inputfield and recordEditForm
       
       event.preventDefault(); // stop form submission
       var eventFields = event.getParam("fields");
       eventFields["Bridger_check__c"] = "";
        eventFields["BillingCountry"] = eventFields["Billing_Country__c"];
       component.find('myform').submit(eventFields); 
           
    },
    handleSuccess : function(component, event, helper) {
        
    //Redirect to detail page on success
    var payload = event.getParams().response;
     var navService = component.find("navService");
        var pageReference = {
            type: 'standard__recordPage',
            attributes: {
                "recordId": payload.id,
                "objectApiName": "Account",
                "actionName": "view"
            }
        }
        event.preventDefault();
        navService.navigate(pageReference);
    }
    
 


})

Aura Component 

<aura:component implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" controller="AccountController">
    <aura:attribute name="accountInfo" type="Account"/>
    <aura:attribute name="bridge" type="Boolean"/>
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>
        Account: {!v.accountInfo.Bridger_check__c}
    

        <aura:attribute name="disabled" type="Boolean" default="false" />
    <aura:attribute name="saved" type="Boolean" default="false" />
    <aura:attribute name="showSpinner" type="Boolean" default="true" />
    <lightning:navigation aura:id="navService"/>
    
    <aura:if isTrue="{!v.bridge}">
    <aura:if isTrue="{!v.showSpinner}">
        <lightning:spinner />
    </aura:if>
    <aura:if isTrue="{!!v.saved}">
        <lightning:recordEditForm
            aura:id="myform"
            onload="{!c.handleLoad}"
            onsubmit="{!c.handleSubmit}"
            onsuccess="{!c.handleSuccess}"
            recordId="{!v.recordId}"
            objectApiName="Account">
            <!-- the messages component is for error messages -->
            <lightning:messages />
             Account Information
            <lightning:inputField fieldName="Region__c" />
            <lightning:inputField fieldName="Country__c" />
            <lightning:inputField fieldName="Segment__c" />      
             <lightning:inputField fieldName="Name" /> 
            <lightning:inputField fieldName="Account Site" /> 
        
         
            
            <div class="slds-m-top_medium">
                <lightning:button disabled="{!v.disabled}" variant="brand" type="submit" name="save" label="Save" />
            </div>
        </lightning:recordEditForm>
        <aura:set attribute="else">
            <p>Saved!</p>
        </aura:set>
    </aura:if>
  
    </aura:if>
    
    <aura:if isTrue="{!!v.bridge}">
        "Not good"
    </aura:if>
    
</aura:component>

Apex controller 
@AuraEnabled
  public static Account getAcc(String accid) {
           return [SELECT id,Bridger_check__c
            FROM Account
            WHERE id =: accid
            LIMIT 1];
    }


But after i press save the record type the same. 
Normally if the record is updated then it should change it's record type.

Any ideas ? 
  • March 11, 2019
  • Like
  • 0
I try to get a specified field from the account that im in, but for some reason i can't . Here is my code
Aura comp:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" controller="AccountController">
    <aura:attribute name="account" type="Account[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>
</aura:component>

Js controller 
({
    init : function(component, event, helper) {
        
        var action = component.get("c.getAcc");
        action.setParams({
            "accid": component.get("v.recordId")                    
        }); 
        
         action.setCallback(this, function(a) {
            component.set("v.account", a.getReturnValue());
        });
        $A.enqueueAction(action);

        var test = component.get("v.account");
        alert(test.Bridger_check__c);
       
    }
})

Apex controller 
 @AuraEnabled
    public static List<Account> getAcc(String accid) {
           return [SELECT id,Bridger_check__c
            FROM Account
            WHERE id =: accid 
            LIMIT:1]; 
            
        }

 
  • March 11, 2019
  • Like
  • 0
I'm trying to display a heatmap on the leaflet map but the coloring is not working. Here is the llibrary that i use  and the code 

I use this for heatmap https://github.com/Leaflet/Leaflet.heat

var map = L.map('map', {zoomControl: true, tap: false, preferCanvas:true})
var baseLayer = { };

var locationsAccounts = new Array(accounts.length);

var heatmapLayer = L.heatLayer([0,0],{ radius: 20,
blur: 15,
maxZoom: 10,
max: 1.0,
gradient: {
          0.0: 'green',
          0.5: 'yellow',
           1.0: 'red'
         }
});
var overlays = { "Heatmap": heatmapLayer };

L.control.layers(baseLayer, overlays).addTo(map);

for (var i=0, len = accounts.length; i<len; i++) {
locationsAccounts[i]=[accounts[i].Latitude, accounts[i].Longitude,0.5]; }
heatmapLayer.setLatLngs(locationsAccounts);
  • February 13, 2019
  • Like
  • 0
I have 60000 accounts that  i want to display on the map  but it gives me unrsponisve page. I tried like this 

var markerList = [];
        var myRenderer = L.canvas({ padding: 0.5 });  // iv read that is better to use a canvas 
        var markers = L.markerClusterGroup( { 
            chunkedLoading: true,   // i found that this prevent the webpage to be unresponsive but acually it does not
            chunkInterval: 300,
            iconCreateFunction: function  (cluster) {
            var childCount = cluster.getChildCount();
              
            var c = ' marker-cluster-';
            if (childCount < 10) {
                c += 'small';
            } 
            else if (childCount < 100) {
                c += 'medium';
            } 
                else {
                    c += 'large';
                }
            
            return new L.DivIcon({ html: '<div><span>' + childCount + '</span></div>', 
                                  className: 'marker-cluster' + c, iconSize: new L.Point(40, 40) });
             }
        });
        
         map.addLayer(markers);    // i added the markers(with nothing in) to the map just to create the connection between map and markers 

        
        //add for each account a marker on map with the posibility to see the distance and to open the rute in google maps
        for (var i=0; i<accounts.length; i++) {
            var account = accounts[i];
          
            var marker = L.marker(latLng, {icon:marker}, {account: account},{renderer: myRenderer})
           
            markerList.push(marker);

        }
         markers.addLayers(markerList); // i added the markerlist to the markers and automatically the map is pupdated because map from leaflet has a marker watcher that detects every change of markers 


My problem is that i could not find a more efficent way to upload markers on the map  and the maximum number of markers that i can add now is around 20000 but no more than that and i need 60k or even more
       
  • February 06, 2019
  • Like
  • 0
I want to return all the accounts a user has and has access to see  for a specific role otherwise to return only the accounts the he has
I tried something like this but is not working
 System.Debug(UserInfo.getUserRoleId());
        if((UserInfo.getUserRoleId()).equals('BOSS')|| (UserInfo.getUserRoleId()).equals('BOSS 2')){
    return [SELECT id, name, AccountStatus__c, OwnerId,
            FROM Account
            LIMIT:100000];
            
        }else {
           return [SELECT id, name, AccountStatus__c, OwnerId, 
            FROM Account
            WHERE OwnerId =: UserInfo.getUserId() 
            LIMIT:100000]; 
  • February 05, 2019
  • Like
  • 0