• Paul Foley
  • NEWBIE
  • 10 Points
  • Member since 2016
  • Salesforce Admin
  • Coretex


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 3
    Replies
Hi All,

I'm putting together an invocable Apex method that gets called when an order is Activated.
The method loops around the products in the order (OrderItems) and create X number of Assets based on the quantity value of the order line.
This means I end up with a loop inside a loop. I'm not hitting limits yet, but am concerned that I could once we move the code to production.

Here's the offending code:
for(OrderItem prod : [select OrderItem.Product2.name, CurrencyIsoCode, id, Product2Id, Quantity, UnitPrice, OrderItem.Order.AccountId, OrderId from OrderItem where OrderId in : oids and OrderItem.Pricebookentry.product2.Is_Asset__c = true]){
            for (integer i = 0; i < prod.Quantity; i++) {
                Asset a = new Asset();
                a.name = prod.Product2.name;
                a.AccountId = prod.Order.AccountId;
                a.Price = prod.UnitPrice;
                a.Product2Id = prod.Product2Id;
                a.Quantity = 1;
                a.CurrencyIsoCode = prod.CurrencyIsoCode;
                a.Status = 'Purchased';
                a.Order_Product__c = prod.id;                

            	newAssets.add(a);
            }
        }

insert newAssets;



 
I'm passing this challenge, however when I actually test it out by clicking on an account in the account list item, I get this exception: 

"Something has gone wrong. Action failed: c$AccountMap$controller$accountSelected [TypeError: Cannot read property 'reuseTiles' of undefined] Failing descriptor: {c$AccountMap$controller$accountSelected}."

I did some debugging and found that the location and latitude of the account are indeed being capture by my event, so it looks like this might be a problem with the leaflet function map.panTo(). Does anyone know the solution to this issue? Here's my code, although it's exactly the same as the tutorial's.
 
({
    jsLoaded: function(component, event, helper) {

        setTimeout(function() {
            var map = L.map('map', {zoomControl: false}).setView([37.784173, -122.401557], 14);
            L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',
                {
                    attribution: 'Tiles © Esri'
                }).addTo(map);
            component.set("v.map", map);
        });
    },

    accountsLoaded: function(component, event, helper) {

        // Add markers
        var map = component.get('v.map');
        var accounts = event.getParam('accounts');
        for (var i=0; i<accounts.length; i++) {
            var account = accounts[i];
            var latLng = [account.Location__Latitude__s, account.Location__Longitude__s];
            L.marker(latLng, {account: account}).addTo(map);
        }  
    },

    accountSelected: function(component, event, helper) {
        // Center the map on the account selected in the list
        var map = component.get('v.map');
        var account = event.getParam("account");
        alert(account.Location__Latitude__s + ', ' + account.Location__Longitude__s);
        map.panTo([account.Location__Latitude__s, account.Location__Longitude__s]);
    }
})

 
Hello

I am not sure if this is possible or not,but i am having a requirement like this.
When we are  sending email from a case(for example) ,sometimes my users get distracted leaving the email aside for sometime.I want an auto save feature to save them to a object when it doenst find any activity on this.

Is this possible?
Or else having a save draft button which saves to salesforce and retrive when needed or when user wants to work on it.
Is this possible.?
Any pointers regrding this please.

Thanks in advance!!