• Narendra Reddy 13
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 4
    Replies
Hi Everyone,
I am new to lightning component, i have written code for upload multiple files upload. But for me working only single file upload. Can anybody help me to resolve this issue. Below are the code details:
Apex Controller:
public with sharing class overrideStandabuttonwithLC {
     @AuraEnabled
    public static ID saveAccount(RFP_Request__c accRec, RFP_Request__c rfplkp)
    {
        try
        {
            accRec.RFP_Manager__c=rfplkp.RFP_Manager__c;
            insert accRec;
        }
        catch(Exception e)
        {
            system.debug('e-->' + e.getMessage());
        }
        
        return accRec.Id;
    } 
    @AuraEnabled
    public static Id saveChunk(Id parentId, String fileName, String base64Data, String contentType, String fileId) {
        // check if fileId id ''(Always blank in first chunk), then call the saveTheFile method,
        //  which is save the check data and return the attachemnt Id after insert, 
        //  next time (in else) we are call the appentTOFile() method
        //   for update the attachment with reamins chunks   
        if (fileId == '') {
            fileId = saveTheFile(parentId, fileName, base64Data, contentType);
        } else {
            appendToFile(fileId, base64Data);
        }
         return Id.valueOf(fileId);
    }
     public static Id saveTheFile(Id parentId, String fileName, String base64Data, String contentType) {
        base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
         Attachment oAttachment = new Attachment();
        oAttachment.parentId = parentId;
         oAttachment.Body = EncodingUtil.base64Decode(base64Data);
        oAttachment.Name = fileName;
        oAttachment.ContentType = contentType;
         insert oAttachment;
         return oAttachment.Id;
    }
     private static void appendToFile(Id fileId, String base64Data) {
        base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
         Attachment a = [
            SELECT Id, Body
            FROM Attachment
            WHERE Id =: fileId
        ];
         String existingBody = EncodingUtil.base64Encode(a.Body);
         a.Body = EncodingUtil.base64Decode(existingBody + base64Data);
         update a;
    } 
  }
Component:
<aura:component implements="lightning:actionOverride,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="overrideStandabuttonwithLC">
    
    <aura:attribute name="rfp" type="RFP_Request__c" default="{'sobjectType': 'RFP_Request__c'}" />
    <aura:attribute name="silookup" type="sObject" default="{}"/> 
    <aura:attribute name="sample" type="String" default="Pranamics"/>
    <aura:attribute name="parentId" type="Id" />
    <aura:attribute name="showLoadingSpinner" type="boolean" default="false"/>
    <aura:attribute name="fileName" type="String" default="No File Selected.." />
    <aura:handler name="init" value="{!this}" action="{!c.onload}"/>
    <div class="slds-page-header css-slider-wrapper">
        
        <div class="slds-page-header css-slider-wrapper">
            <div class="slds-grid css-slider-wrapper">
                <div class="slds-col css-slider-wrapper slds-has-flexi-truncate">
                    <center> <p class="slds-text-heading--label"><b>New RFP Request</b></p></center>
                    <div class="slds-grid css-slider-wrapper">
                        <div class="slds-m-around--medium">
                            <center><button class="slds-button slds-button--brand" onclick="{!c.createrfprequ}">Save</button></center>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="slds-page-header">
            <div class="slds-grid">
                <div class="slds-col slds-has-flexi-truncate">
                    <p class="slds-text-heading--label">RFP Request Information</p>
                    <div class="slds-grid">
                     </div>
                </div>
            </div>
        </div>
                <div class="slds-page-header css-slider-wrapper">
            <div class="slds-grid css-slider-wrapper">
                <div class="slds-col slds-has-flexi-truncate css-slider-wrapper">
                    <div class="slds-form-element__control css-slider-wrapper">
                        <lightning:layout horizontalAlign="space">
                            
                            <lightning:layoutitem padding="around-small" flexibility="auto" >
                                <ui:inputText label="Name" value="{!v.rfp.Name}" class="slds-input" required="true"/>
                                <ui:inputText aura:id="Issued_By__c" label="Issued Company" value="{!v.rfp.Issued_By__c}" class="slds-input" required="true"/>
                                <ui:inputText aura:id="Representative_Name__c" label="Representative Name" value="{!v.rfp.Representative_Name__c}" class="slds-input" required="true"/>
                                <ui:inputText aura:id="Representative_Email_Id__c" label="Representative Email Id" value="{!v.rfp.Representative_Email_Id__c}" class="slds-input" required="true"/> 
                                <ui:inputText aura:id="Representative_Phone__c" label="Representative Phone" value="{!v.rfp.Representative_Phone__c}" class="slds-input" required="true"/>
                            </lightning:layoutitem>
                            
                            <lightning:layoutitem padding="around-small" flexibility="auto" >
                                <div>* RFP Manager</div>
                                <c:customlookup objectAPIName="user" IconName="standard:user" selectedRecord="{!v.silookup}"/>
                                <ui:inputDate aura:id="Issued_Date__c" label="Issued Date" value="{!v.rfp.Issued_Date__c}" class="slds-input" displayDatePicker="true" required="true"/>
                                <ui:inputDate aura:id="Dead_Line_Date__c" label="Deadline Date" value="{!v.rfp.Dead_Line_Date__c}" class="slds-input" displayDatePicker="true" required="true"/>
                            </lightning:layoutitem>
                        </lightning:layout>
                    </div>
                    <div class="slds-grid">
                    </div>
                </div>
            </div>
        </div>
        <div class="slds-page-header" role="banner">
            <lightning:input aura:id="fileId" onchange="{!c.handleFilesChange}" type="file" name="file" label="Upload Attachment" multiple="true"/>
            <div class="slds-text-body_small slds-text-color_error">{!v.fileName} </div>
            
            <!--use aura:if for show-hide the loading spinner image--> 
            <aura:if isTrue="{!v.showLoadingSpinner}">
                <div class="slds-text-body_small slds-text-color_error">Uploading... 
                    <img src="/auraFW/resources/aura/images/spinner.gif" class="spinner-img" alt="Loading"/>
                </div>
            </aura:if>
            <br/>
            <!-- <button class="slds-button slds-button_brand" onclick="{!c.doSave}">Upload Attachment</button>-->    
        </div>
        
        
        <div class="slds-m-around--medium">
            <center><button class="slds-button slds-button--brand" onclick="{!c.createrfprequ}">Save</button></center>
        </div>
    </div>
</aura:component>

JS Controller:
({
    onload : function(component, event, helper) 
    {
        
    },
    createrfprequ : function(component, event, helper) 
    {
        var action = component.get("c.saveAccount");
        var rfp = component.get("v.rfp");
        
        var name = JSON.stringify(component.get("v.rfp.Name"));
        if($A.util.isEmpty(name) || $A.util.isUndefined(name))
        {
            alert('Please enter a name.');
            return;
        }
        if($A.util.isEmpty(rfp.Issued_By__c) || $A.util.isUndefined(rfp.Issued_By__c))
        {
            alert('Please enter a Issued Company.');
            return;
        }
        if($A.util.isEmpty(rfp.Representative_Name__c) || $A.util.isUndefined(rfp.Representative_Name__c))
        {
            alert('Please enter a Representative Name.');
            return;
        }
        if($A.util.isEmpty(rfp.Representative_Email_Id__c) || $A.util.isUndefined(rfp.Representative_Email_Id__c))
        {
            alert('Please enter a Representative Email Id.');
            return;
        }
        
        if($A.util.isEmpty(rfp.Representative_Phone__c) || $A.util.isUndefined(rfp.Representative_Phone__c))
        {
            alert('Please select a Representative Phone.');
            return;
        }
        if(component.get("v.silookup").Id == undefined)
        {
            alert('Please select a RFP Manager.');
            return;
        }
        
        if($A.util.isEmpty(rfp.Issued_Date__c) || $A.util.isUndefined(rfp.Issued_Date__c))
        {
            alert('Please select an Issued Date.');
            return;
        }
        
        if($A.util.isEmpty(rfp.Dead_Line_Date__c) || $A.util.isUndefined(rfp.Dead_Line_Date__c))
        {
            alert('Please select an Deadline Date.');
            return;
        }
         // file upload button 
        if (component.find("fileId").get("v.files").length > 0) 
        {
           
        } 
        else
        {
            alert('Please Select a Valid File');
            return;
        }                            
        rfp.RFP_Manager__c = null ; 
        
        if(component.get("v.silookup").Id != undefined){
            rfp.RFP_Manager__c = component.get("v.silookup").Id;
        }
           action.setParams({
            accRec:component.get("v.rfp"),
            rfplkp:rfp
        });
        
        action.setCallback(this, function(response)
         {
             if(response.getState()==='SUCCESS')
             {
                 var rfpid = response.getReturnValue();
                 
                 if (component.find("fileId").get("v.files").length > 0) 
                 {
                     helper.uploadHelper(component, event);
                 } 
                 component.set("v.parentId", rfpid); 
                 
                 var toastEvent = $A.get("e.force:showToast");
                 toastEvent.setParams({
                     "title": "Success!",
                     "type":"Success",
                     "message": "RFP Request has been created successfully."
                 });
                 toastEvent.fire();
                 
                 var navEvt = $A.get("e.force:navigateToSObject");
                 navEvt.setParams({
                     "recordId":  rfpid,
                     "slideDevName": "related"
                 });
                 navEvt.fire();
             }
         });
        $A.enqueueAction(action);
    },
    
    onCancel : function(component, event, helper) {
        
        // Navigate back to the record view
        var navigateEvent = $A.get("e.force:navigateToSObject");
        navigateEvent.setParams({ "recordId": component.get('v.recordId') });
        navigateEvent.fire();
    },
    
    doSave: function(component, event, helper) {
        if (component.find("fileId").get("v.files").length > 0) {
            helper.uploadHelper(component, event);
        } else {
            alert('Please Select a Valid File');
        }
    },
    
    handleFilesChange: function(component, event, helper) {
        var fileName = 'No File Selected..';
        if (event.getSource().get("v.files").length > 0) {
            fileName = event.getSource().get("v.files")[0]['name'];
        }
        component.set("v.fileName", fileName);
    },
   
})

 
Hi Every One,

Can any body help me out resolve this issue.
Scinario: Under Work Order i have products consumed related list, here i am adding products from Products2 (PriceBookEntry).
When click on Add Products button it will open vf page. In vf page select option (Wrapper Class) i am getting error Collection size exceeded maximum 1000.
I have Products 1300+.

It needs urgent. Thanks In Advance.
Hi ALL,

Can any body know how can we use chatter in field service lightning.
Hi Everyone, anybody can help me out to restrict to particuler users see their own accounts only.

Ex: I have Force.com Profile, it is assigned to A and B user. I need to restrict these users see their own accounts only.
Hi Every one,
I am new to Salesforce. I need to impliment visualforce page in Salesforce1.
My requirment is Under Account i have Order custom object related list. Here i  have "New Order" custom visualforce button. When i click on this button it will open Order form, here i need to insert order line items.These Order Line items getting from Product records (Custom Object).

Below Ex Order form:
User-added image

Can anybody suggest me how to implement visualforce to display in salesforce1.
I have below these four fileds.
Morning_Sign_In__c
Afternoon_Sign_Off__c
Afternoon_Sign_In__c
Evening_Sign_Off__c

When the employee morning sign in and afternoon sign off for lunch break and after lunch login and evening logout. in between this situation i need calculate the total working hours of the day in 12 hours format
I have below these four fileds.
Morning_Sign_In__c
Afternoon_Sign_Off__c
Afternoon_Sign_In__c
Evening_Sign_Off__c

When the employee morning sign in and afternoon sign off for lunch break and after lunch login and evening logout. in between this situation i need calculate the total working hours of the day in 12 hours format
Hi Everyone,
I am new to lightning component, i have written code for upload multiple files upload. But for me working only single file upload. Can anybody help me to resolve this issue. Below are the code details:
Apex Controller:
public with sharing class overrideStandabuttonwithLC {
     @AuraEnabled
    public static ID saveAccount(RFP_Request__c accRec, RFP_Request__c rfplkp)
    {
        try
        {
            accRec.RFP_Manager__c=rfplkp.RFP_Manager__c;
            insert accRec;
        }
        catch(Exception e)
        {
            system.debug('e-->' + e.getMessage());
        }
        
        return accRec.Id;
    } 
    @AuraEnabled
    public static Id saveChunk(Id parentId, String fileName, String base64Data, String contentType, String fileId) {
        // check if fileId id ''(Always blank in first chunk), then call the saveTheFile method,
        //  which is save the check data and return the attachemnt Id after insert, 
        //  next time (in else) we are call the appentTOFile() method
        //   for update the attachment with reamins chunks   
        if (fileId == '') {
            fileId = saveTheFile(parentId, fileName, base64Data, contentType);
        } else {
            appendToFile(fileId, base64Data);
        }
         return Id.valueOf(fileId);
    }
     public static Id saveTheFile(Id parentId, String fileName, String base64Data, String contentType) {
        base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
         Attachment oAttachment = new Attachment();
        oAttachment.parentId = parentId;
         oAttachment.Body = EncodingUtil.base64Decode(base64Data);
        oAttachment.Name = fileName;
        oAttachment.ContentType = contentType;
         insert oAttachment;
         return oAttachment.Id;
    }
     private static void appendToFile(Id fileId, String base64Data) {
        base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
         Attachment a = [
            SELECT Id, Body
            FROM Attachment
            WHERE Id =: fileId
        ];
         String existingBody = EncodingUtil.base64Encode(a.Body);
         a.Body = EncodingUtil.base64Decode(existingBody + base64Data);
         update a;
    } 
  }
Component:
<aura:component implements="lightning:actionOverride,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="overrideStandabuttonwithLC">
    
    <aura:attribute name="rfp" type="RFP_Request__c" default="{'sobjectType': 'RFP_Request__c'}" />
    <aura:attribute name="silookup" type="sObject" default="{}"/> 
    <aura:attribute name="sample" type="String" default="Pranamics"/>
    <aura:attribute name="parentId" type="Id" />
    <aura:attribute name="showLoadingSpinner" type="boolean" default="false"/>
    <aura:attribute name="fileName" type="String" default="No File Selected.." />
    <aura:handler name="init" value="{!this}" action="{!c.onload}"/>
    <div class="slds-page-header css-slider-wrapper">
        
        <div class="slds-page-header css-slider-wrapper">
            <div class="slds-grid css-slider-wrapper">
                <div class="slds-col css-slider-wrapper slds-has-flexi-truncate">
                    <center> <p class="slds-text-heading--label"><b>New RFP Request</b></p></center>
                    <div class="slds-grid css-slider-wrapper">
                        <div class="slds-m-around--medium">
                            <center><button class="slds-button slds-button--brand" onclick="{!c.createrfprequ}">Save</button></center>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="slds-page-header">
            <div class="slds-grid">
                <div class="slds-col slds-has-flexi-truncate">
                    <p class="slds-text-heading--label">RFP Request Information</p>
                    <div class="slds-grid">
                     </div>
                </div>
            </div>
        </div>
                <div class="slds-page-header css-slider-wrapper">
            <div class="slds-grid css-slider-wrapper">
                <div class="slds-col slds-has-flexi-truncate css-slider-wrapper">
                    <div class="slds-form-element__control css-slider-wrapper">
                        <lightning:layout horizontalAlign="space">
                            
                            <lightning:layoutitem padding="around-small" flexibility="auto" >
                                <ui:inputText label="Name" value="{!v.rfp.Name}" class="slds-input" required="true"/>
                                <ui:inputText aura:id="Issued_By__c" label="Issued Company" value="{!v.rfp.Issued_By__c}" class="slds-input" required="true"/>
                                <ui:inputText aura:id="Representative_Name__c" label="Representative Name" value="{!v.rfp.Representative_Name__c}" class="slds-input" required="true"/>
                                <ui:inputText aura:id="Representative_Email_Id__c" label="Representative Email Id" value="{!v.rfp.Representative_Email_Id__c}" class="slds-input" required="true"/> 
                                <ui:inputText aura:id="Representative_Phone__c" label="Representative Phone" value="{!v.rfp.Representative_Phone__c}" class="slds-input" required="true"/>
                            </lightning:layoutitem>
                            
                            <lightning:layoutitem padding="around-small" flexibility="auto" >
                                <div>* RFP Manager</div>
                                <c:customlookup objectAPIName="user" IconName="standard:user" selectedRecord="{!v.silookup}"/>
                                <ui:inputDate aura:id="Issued_Date__c" label="Issued Date" value="{!v.rfp.Issued_Date__c}" class="slds-input" displayDatePicker="true" required="true"/>
                                <ui:inputDate aura:id="Dead_Line_Date__c" label="Deadline Date" value="{!v.rfp.Dead_Line_Date__c}" class="slds-input" displayDatePicker="true" required="true"/>
                            </lightning:layoutitem>
                        </lightning:layout>
                    </div>
                    <div class="slds-grid">
                    </div>
                </div>
            </div>
        </div>
        <div class="slds-page-header" role="banner">
            <lightning:input aura:id="fileId" onchange="{!c.handleFilesChange}" type="file" name="file" label="Upload Attachment" multiple="true"/>
            <div class="slds-text-body_small slds-text-color_error">{!v.fileName} </div>
            
            <!--use aura:if for show-hide the loading spinner image--> 
            <aura:if isTrue="{!v.showLoadingSpinner}">
                <div class="slds-text-body_small slds-text-color_error">Uploading... 
                    <img src="/auraFW/resources/aura/images/spinner.gif" class="spinner-img" alt="Loading"/>
                </div>
            </aura:if>
            <br/>
            <!-- <button class="slds-button slds-button_brand" onclick="{!c.doSave}">Upload Attachment</button>-->    
        </div>
        
        
        <div class="slds-m-around--medium">
            <center><button class="slds-button slds-button--brand" onclick="{!c.createrfprequ}">Save</button></center>
        </div>
    </div>
</aura:component>

JS Controller:
({
    onload : function(component, event, helper) 
    {
        
    },
    createrfprequ : function(component, event, helper) 
    {
        var action = component.get("c.saveAccount");
        var rfp = component.get("v.rfp");
        
        var name = JSON.stringify(component.get("v.rfp.Name"));
        if($A.util.isEmpty(name) || $A.util.isUndefined(name))
        {
            alert('Please enter a name.');
            return;
        }
        if($A.util.isEmpty(rfp.Issued_By__c) || $A.util.isUndefined(rfp.Issued_By__c))
        {
            alert('Please enter a Issued Company.');
            return;
        }
        if($A.util.isEmpty(rfp.Representative_Name__c) || $A.util.isUndefined(rfp.Representative_Name__c))
        {
            alert('Please enter a Representative Name.');
            return;
        }
        if($A.util.isEmpty(rfp.Representative_Email_Id__c) || $A.util.isUndefined(rfp.Representative_Email_Id__c))
        {
            alert('Please enter a Representative Email Id.');
            return;
        }
        
        if($A.util.isEmpty(rfp.Representative_Phone__c) || $A.util.isUndefined(rfp.Representative_Phone__c))
        {
            alert('Please select a Representative Phone.');
            return;
        }
        if(component.get("v.silookup").Id == undefined)
        {
            alert('Please select a RFP Manager.');
            return;
        }
        
        if($A.util.isEmpty(rfp.Issued_Date__c) || $A.util.isUndefined(rfp.Issued_Date__c))
        {
            alert('Please select an Issued Date.');
            return;
        }
        
        if($A.util.isEmpty(rfp.Dead_Line_Date__c) || $A.util.isUndefined(rfp.Dead_Line_Date__c))
        {
            alert('Please select an Deadline Date.');
            return;
        }
         // file upload button 
        if (component.find("fileId").get("v.files").length > 0) 
        {
           
        } 
        else
        {
            alert('Please Select a Valid File');
            return;
        }                            
        rfp.RFP_Manager__c = null ; 
        
        if(component.get("v.silookup").Id != undefined){
            rfp.RFP_Manager__c = component.get("v.silookup").Id;
        }
           action.setParams({
            accRec:component.get("v.rfp"),
            rfplkp:rfp
        });
        
        action.setCallback(this, function(response)
         {
             if(response.getState()==='SUCCESS')
             {
                 var rfpid = response.getReturnValue();
                 
                 if (component.find("fileId").get("v.files").length > 0) 
                 {
                     helper.uploadHelper(component, event);
                 } 
                 component.set("v.parentId", rfpid); 
                 
                 var toastEvent = $A.get("e.force:showToast");
                 toastEvent.setParams({
                     "title": "Success!",
                     "type":"Success",
                     "message": "RFP Request has been created successfully."
                 });
                 toastEvent.fire();
                 
                 var navEvt = $A.get("e.force:navigateToSObject");
                 navEvt.setParams({
                     "recordId":  rfpid,
                     "slideDevName": "related"
                 });
                 navEvt.fire();
             }
         });
        $A.enqueueAction(action);
    },
    
    onCancel : function(component, event, helper) {
        
        // Navigate back to the record view
        var navigateEvent = $A.get("e.force:navigateToSObject");
        navigateEvent.setParams({ "recordId": component.get('v.recordId') });
        navigateEvent.fire();
    },
    
    doSave: function(component, event, helper) {
        if (component.find("fileId").get("v.files").length > 0) {
            helper.uploadHelper(component, event);
        } else {
            alert('Please Select a Valid File');
        }
    },
    
    handleFilesChange: function(component, event, helper) {
        var fileName = 'No File Selected..';
        if (event.getSource().get("v.files").length > 0) {
            fileName = event.getSource().get("v.files")[0]['name'];
        }
        component.set("v.fileName", fileName);
    },
   
})

 
Hi Every One,

Can any body help me out resolve this issue.
Scinario: Under Work Order i have products consumed related list, here i am adding products from Products2 (PriceBookEntry).
When click on Add Products button it will open vf page. In vf page select option (Wrapper Class) i am getting error Collection size exceeded maximum 1000.
I have Products 1300+.

It needs urgent. Thanks In Advance.
I have below these four fileds.
Morning_Sign_In__c
Afternoon_Sign_Off__c
Afternoon_Sign_In__c
Evening_Sign_Off__c

When the employee morning sign in and afternoon sign off for lunch break and after lunch login and evening logout. in between this situation i need calculate the total working hours of the day in 12 hours format