• Ranjan Kumar 78
  • -1 Points
  • Member since 2019

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 3
I would like to create a custom action to download record attachments as a zip in LightningExperience.
I created a controller and Visualforce to download attachments obtained using zippex https://github.com/pdalcol/Zippex.
public class ImageZipController {
  public final ParentObject__c parent {get; set;}
  private Id parentObjId;
  public ImageZipController(ApexPages.StandardController stdController) {
      this.order = (order__c)stdController.getRecord();
    public PageReference downloadAttachments(){
	orderId = order.Id;

    String objectId = parentObjId;
    String docName =  'test.zip'; 
    List<Attachment> attachments = [SELECT Name, Body FROM Attachment WHERE ParentId = :objectId];
    System.debug('>>> attachments ' + attachments.size());
    Zippex sampleZip = new Zippex();
    for(Attachment file : attachments) {
      sampleZip.addFile('folder/' + file.Name, file.Body, null);
      Document doc = new Document();
      doc.FolderId = UserInfo.getUserId();
      doc.Name = docName;
      doc.Body = sampleZip.getZipArchive();
      insert doc;
      System.debug('>>> doc ' + doc.Id);
      return new PageReference('/servlet/servlet.FileDownload?file=' + doc.Id);
    } catch ( Exception ex ) {
      System.debug('>>> ERROR ' + ex);
    return null;


But even small files will give errors.
Error: System.LimitException: Apex CPU time limit exceeded

I researched myself and found that using @future can avoid it, but I don't know what code to write.
I do not have enough knowledge as a developer.
Please Help me.
We use Product Schedules (both Quantity & Revenue). When we schedule over 6 months it divides the quantity & revenue equally over 6 months. 
LAter when a sales rep goes and modifies the quantity, then selectes the recalculate button the Quantity is updated BUT the revenue is not recalculated.

SFDC Support suggested using VisualForce - Does anyone have some code I can build from?
I've managed to create a lightning homepage component with 1 column using the below component, style, and design elements. If I re-use the {!v.main} in the component page more than once, I receive an error. 

I want to be able to create 3 horizontal sections as shown in the last image below. Is it possible? 

<aura:component implements="lightning:homeTemplate">
    <aura:attribute name="main" type="Aura.Component[]" /> 
        <lightning:layout horizontalAlign="spread">

<flexipage:template >
        <flexipage:region name="main" defaultWidth="Xlarge">

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="120px" height="120px" viewBox="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
	<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
		<path d="M120,108 C120,114.6 114.6,120 108,120 L12,120 C5.4,120 0,114.6 0,108 L0,12 C0,5.4 5.4,0 12,0 L108,0 C114.6,0 120,5.4 120,12 L120,108 L120,108 Z" id="Shape" fill="#2A739E"/>
		<path d="M77.7383308,20 L61.1640113,20 L44.7300055,63.2000173 L56.0543288,63.2000173 L40,99.623291 L72.7458388,54.5871812 L60.907727,54.5871812 L77.7383308,20 Z" id="Path-1" fill="#FFFFFF"/>

This is the error I receive
User-added image

This is the layout I can render but doesn't work if I add components to it
User-added image