• Harshada
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 8
    Replies
Component JS:
({
   /* closeModel :function(component, event, helper) {
        //  component.set('v.isOpen', false);
         var recId1 = component.get("v.recordId");
       window.location.href='/lightning/r/Account/'+recId1+'/view';
    },*/
   handleFilesChange: function(component, event, helper) {
        var fileName = 'No File Selected..';
        var ext;
        component.set('v.showSpinner', true);
        if (event.getSource().get("v.files").length > 0) {
            fileName = event.getSource().get("v.files")[0]['name'];
            ext = fileName.substring(fileName.length-3,fileName.length);
        }
        component.set("v.fileName", fileName);
        if(ext=='csv'){
            var fileInput = component.find("file").get("v.files");
            var file = fileInput[0];
            if (file) {
                var reader = new FileReader();
                reader.readAsText(file, "UTF-8");
                reader.onload = function (evt) {
                    var csv = evt.target.result;
                    window.setTimeout($A.getCallback(function(){
                        helper.FetchData(component,csv);
                    }), 10);
                }
                reader.onerror = function (evt) {
                }
            }
        }
        else {
            component.set("v.errorMessage",'Kindly select a CSV file.');
            component.set('v.showSpinner', false);
        }
    },


   showAlert : function(component, event, helper) {
     alert('Test Alert');
    }

})
*******************************************************************************
Component helper:
({
    FetchData : function (component,csvData){
          var recId1 = component.get("v.recordId");
      
       // var fname = component.get("v.fileName");
        var recId = component.get("v.recordId");
        var action = component.get("c.insertData");
        action.setParams({
            "strfromlex" : csvData,
           // "recordId"  : recId
           // "FileName"  : fname
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {  
                var rtnValue = response.getReturnValue();
             //If there is no error in csv file simply show success message
                var toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams({
                    title : 'Success',
                    message: 'File Uploaded Successfully.',
                    duration:'5000',
                    key: 'info_alt',
                    type: 'success',
                    mode: 'sticky'
                });
                toastEvent.fire();
                  $A.get('e.force:refreshView').fire();
                component.set('v.showSpinner', false);
                 window.location.href='/lightning/r/Account/'+recId1+'/view';
               // component.set('v.isOpen', false);
                }
 else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                   // alert(errors);
                    var toastEvent = $A.get("e.force:showToast");
                    toastEvent.setParams({
                        title : 'Error',
                        message:'There were failures while file upload, please check related records.',
                        duration:' 5000',
                        key: 'info_alt',
                        type: 'error',
                        mode: 'sticky'
                    });
                    toastEvent.fire();
                    component.set('v.showSpinner', false);
            }
        }
*******************************************************************************
Vf page:
<apex:page standardController="Account"  recordSetVar="accounts" tabStyle="account" lightningStylesheets="true">
    <apex:includeLightning />
    <div id="lightning">
        
    </div>
    
<script>
 $Lightning.use("c:AccountCsvFileUploadApp", function() {
 $Lightning.createComponent("c:AccountCsvFileUpload",{
 },
                            
"lightning", 
                            
     function(component){
         // component.set('v.isOpen',true);
        component.set("v.strfromlex");
         component.set("v.recordId");
         component.set("v.fileName", fileName);
 });
 });
 </script>
</apex:page>
*******************************************************************************

       
 
Component JS:
({
   /* closeModel :function(component, event, helper) {
        //  component.set('v.isOpen', false);
         var recId1 = component.get("v.recordId");
       window.location.href='/lightning/r/Account/'+recId1+'/view';
    },*/
   handleFilesChange: function(component, event, helper) {
        var fileName = 'No File Selected..';
        var ext;
        component.set('v.showSpinner', true);
        if (event.getSource().get("v.files").length > 0) {
            fileName = event.getSource().get("v.files")[0]['name'];
            ext = fileName.substring(fileName.length-3,fileName.length);
        }
        component.set("v.fileName", fileName);
        if(ext=='csv'){
            var fileInput = component.find("file").get("v.files");
            var file = fileInput[0];
            if (file) {
                var reader = new FileReader();
                reader.readAsText(file, "UTF-8");
                reader.onload = function (evt) {
                    var csv = evt.target.result;
                    window.setTimeout($A.getCallback(function(){
                        helper.FetchData(component,csv);
                    }), 10);
                }
                reader.onerror = function (evt) {
                }
            }
        }
        else {
            component.set("v.errorMessage",'Kindly select a CSV file.');
            component.set('v.showSpinner', false);
        }
    },


   showAlert : function(component, event, helper) {
     alert('Test Alert');
    }

})
*******************************************************************************
Component helper:
({
    FetchData : function (component,csvData){
          var recId1 = component.get("v.recordId");
      
       // var fname = component.get("v.fileName");
        var recId = component.get("v.recordId");
        var action = component.get("c.insertData");
        action.setParams({
            "strfromlex" : csvData,
           // "recordId"  : recId
           // "FileName"  : fname
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {  
                var rtnValue = response.getReturnValue();
             //If there is no error in csv file simply show success message
                var toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams({
                    title : 'Success',
                    message: 'File Uploaded Successfully.',
                    duration:'5000',
                    key: 'info_alt',
                    type: 'success',
                    mode: 'sticky'
                });
                toastEvent.fire();
                  $A.get('e.force:refreshView').fire();
                component.set('v.showSpinner', false);
                 window.location.href='/lightning/r/Account/'+recId1+'/view';
               // component.set('v.isOpen', false);
                }
 else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                   // alert(errors);
                    var toastEvent = $A.get("e.force:showToast");
                    toastEvent.setParams({
                        title : 'Error',
                        message:'There were failures while file upload, please check related records.',
                        duration:' 5000',
                        key: 'info_alt',
                        type: 'error',
                        mode: 'sticky'
                    });
                    toastEvent.fire();
                    component.set('v.showSpinner', false);
            }
        }
*******************************************************************************
Vf page:
<apex:page standardController="Account"  recordSetVar="accounts" tabStyle="account" lightningStylesheets="true">
    <apex:includeLightning />
    <div id="lightning">
        
    </div>
    
<script>
 $Lightning.use("c:AccountCsvFileUploadApp", function() {
 $Lightning.createComponent("c:AccountCsvFileUpload",{
 },
                            
"lightning", 
                            
     function(component){
         // component.set('v.isOpen',true);
        component.set("v.strfromlex");
         component.set("v.recordId");
         component.set("v.fileName", fileName);
 });
 });
 </script>
</apex:page>
*******************************************************************************

       
 
Hi. I've been looking for official documentaion on the number of decision elements you can have in one decision box in a flow?  We had 34 but only 21 actually evaulated when running the flow.  Raised the question with Salesforce support but they said they don't know and to post it on here.  We have worked around it by splitting into 2 and using criteria on the process flow to decide which one to run, but for future reference it would be good to get an official answer on this. Thank you.
Hi All,

  I have requirement to upload CSV file into Salesforce using lightning component then this record will insert in Sobject records.Please guide me on this scenario.

Thanks,
Santhanam
What is a recursive trigger? What are the best ways to avoid recursive triggers can somebody explain with a simple example.Please help me to understand the concept of recursive triggers.

Thanks
I'm using MS Windows 8.1 with Google Chrome Version 35.0.1916.114 m
I have a free Salesforce trial version

From the "My Name" menu I chose "Developer Console".
I get a new window Force.com Developer Console with the "Loading workspace ..." progress bar.
The progress bar gets hung at about 50%.

Any advice?

Odeddevelopers console will not load