Skip to main content

#Lightning Experience10 人がディスカッション中

Dear Community,

I am new to Lightning experience,i have some knowledge about lightning.i tried to generate the pdf for Account or any standard or custom object.i wrote the some logic the pfd is generated with empty sheet,i want all the fields of the perticular object which is i mentioned.i think i missed some logic in my components/controllers.

can any one suggest where i did mistake and also can tell me how to generate the pdf for perticular object either custom or standard

my code is 

Apex class:

public class DataDisplayController {

    public String PDFData{get;set;}

    

    public DataDisplayController(){

        

        PDFData = '';

    }

    public PageReference downloadPDF(){

        System.PageReference pageRef = new System.PageReference('/apex/PDFGenerator');

        //ensure pdf downloads and is assigned with defined name

        pageRef.getHeaders().put('content-disposition', 'attachment; filename=TestPDF.pdf');

        

        return pageRef;

    }

    }

Component:

<aura:component >

    <aura:attribute name = "sendData" type = "Account"/>

    <lightning:button label = "Download Document" onclick = "{!c.downloadDocument}" />

    

</aura:component>

client-side controller.js

({

 downloadDocument : function(component, event, helper){

  var sendDataProc = component.get("v.sendData");

  var dataToSend = {

     "label" : "This is test"

  }; //this is data you want to send for PDF generation

  //invoke vf page js method

  sendDataProc(dataToSend, function(){

              

  });

 }

})

Helper.js

({

    helperMethod : function(component,callbackMethod) {

        var action = component.get("c.download");

        action.setCallback(this,function(response){

            var state = response.getState();

            if(state === "SUCCESS"){

                var generatePdf = reponse.getReturnValue();

                component.set("v.sendData",generatePdf);

                console.log('pdf generated successfully');

                

            }

            else{

                console.log('unable to generate the pdf');

            }

        });

        $A.enqueueAction(action);

        

    }

})

VF Page:

<apex:page controller="DataDisplayController" showHeader="false">

    <apex:includeLightning />

    

    <apex:form>

        <apex:inputHidden id="hidData" value="{!PDFData}"/>

        <apex:actionFunction name="jsGeneratePDF" action="{!downloadPDF}"/>

        <div id = "lightning" />

        

        <script>

            function saveData(data, callback){

            var hidData = document.getElementById('{!$Component.hidData}');

            hidData.value = JSON.stringify(data);

            

            //invoke PDF Generation

            jsGeneratePDF();

         

            //invoke callback;

            if(typeof callback == 'function') callback();

        }

        

        

        function loadComponents(){

            console.log("Loading lightning component: DataProcessor");

            

            $Lightning.use("c:LightningPDFGeneratorDemoApp", function() {

                $Lightning.createComponent("c:DataProcessor",

                { 

                    sendData : saveData

                },

                "lightning",

                function(cmp) {

                    // do some stuff

                });

            });

        }

        

        loadComponents();

        </script>            

           </apex:form>

</apex:page>

<apex:page controller="DataDisplayController"  renderAs="pdf">

    {!PDFData}

</apex:page>

App:

<aura:application extends = "ltng:outApp" >

    <c:DataProcessor />

    

</aura:application>

thanks in advance
8 件の回答
0/9000
i have lines of code in java which splits the pdf attachement ,. how to use this in salesforce,. 

below is the set of java code.

import org.apache.pdfbox.multipdf.Splitter;

import org.apache.pdfbox.pdmodel.PDDocument;

import java.io.File;

import java.io.IOException;

import java.util.List;

import java.util.Iterator;

public class SplitPages {

public static void main(String[] args) throws IOException {

//Loading an existing PDF document

File file = new File("C:/PdfBox_Examples/sample.pdf");

PDDocument document = PDDocument.load(file);

//Instantiating Splitter class

Splitter splitter = new Splitter();

//splitting the pages of a PDF document

List<PDDocument> Pages = splitter.split(document);

//Creating an iterator

Iterator<PDDocument> iterator = Pages.listIterator();

//Saving each page as an individual document

int i = 1;

while(iterator.hasNext()) {

PDDocument pd = iterator.next();

pd.save("C:/PdfBox_Examples/sample"+ i++ +".pdf");

}

System.out.println("Multiple PDF’s created");

document.close();

}

}

3 件の回答
0/9000
<lightning:buttonMenu alternativeText="Toggle menu" iconSize="x-Small" onselect="{!c.handleMenuSelect}">
2 件の回答
  1. 8月25日 14:10

    In my case I used empty attributes for active and inactive toggle as these were unwanted. It reduced the height

    <lightning-input

       type="toggle"

       label="All"

       message-toggle-active=""

       message-toggle-inactive="">

     </lightning-input> 

0/9000
Dear Team ,

Thank you for clearing my doubts !!!

Is it possible to create Lightning Web Component without installing Visual Studio code ? Through our salesforce account can we create LWC .

Thanks & Regards

Sachin Bhalerao
5 件の回答
  1. 2019年11月1日 9:42
    Hi Sachin,

    Greetings to you!

    You cannot use the Developer Console to develop LWC. To experiment with Lightning Web Components, you can use the Lightning Web Components Playground: https://developer.salesforce.com/docs/component-library/tools/playground

    But there are some limitations:

    1. The playground doesn't provide Security with Lightning Locker.

    2. The playground can’t access Salesforce organizations, so it doesn’t support features that require data from Salesforce.

    https://developer.salesforce.com/docs/component-library/documentation/lwc/install_playground

    As per doc: https://developer.salesforce.com/blogs/2018/12/developer-tools-for-lightning-web-components.html

    There are other IDE as well for developing Lightning Web Component like Illuminated Cloud (https://plugins.jetbrains.com/plugin/10253-illuminated-cloud-2) but Salesforce recommends Visual Studio Code and the Salesforce Lightning Web Components Extension for VS Code. This combination provides powerful connections to the Salesforce CLI from within VS Code, plus additional features specific to developing Lightning web components for Salesforce.

    I hope it helps you.

    Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

    Thanks and Regards,

    Khan Anas

     
0/9000
Hi Devs,  I coded a Lightning Message Service channel in VS Code, deployed to Org, & then due to some issues later deleted it from the  Project AND Org.  But I think the LMS is STILL in the Org coz after cleaning up & deploying again it doesn't allow it and results in an error.

Here's my Q: do you know Where & How in Setup to: a) find Lightning Message Service channels, and b) completely delete them from the Org?

Thanks!! 

 
12 件の回答
  1. 8月4日 16:03

    I don't know if anyone has found solution for this or not, only way to do this is open the Lightning messaging channel in VS code, right click from directory and select "Delete from project and org"

0/9000
I have a requirement wherein I need to send a quote record for approval using Salesforce standard approval process. I've maintained approver user in a custom field(user lookup) on my record. When I click on 'Submit for approval' from Sales portal it gets submitted successfully.

Problem : When I try to submit the 'same' record with a partner user from community portal, I get this error "another user recalled or responded to this request." 

Things that I have already tried:

1. Check if Approval process is active.

2. Check if Approver is active.

3. Create a fresh new record which is not submitted for approval yet. (Did not work for this either, No it was not already approved).

4. Logged in with the approver to check if he/she is able to access the quote record 'Read-Write'. (no sharing problem)

5. When I login as my user (Admin) to community and submit the record, Then I'm able to submit. (So, this cannot be community limitation either).

What am I missing??

Can anyone please help me here?

Thanks,

Priyal

 
4 件の回答
  1. 8月3日 10:58

    Thanks for the direction,  Gustavo Silva . I checked your post, but still spent two days finding a solution! 

     

    For me, the Process Automation Settings for "Automated Process User Email Address" was still pointing to an old "No Reply" ID. When the org-wide address was removed/updated, it should have auto-updated to show or point to the latest one. That was my issue. 

     

    The case is now with Salesforce, and I'm hoping they can help by making the latest address available in the dropdown list — hopefully they can get this fixed. 

0/9000
I using mozilla firefox 66.0b5 (32-bit) version I add list button ( name of button : save) in list view. In Lightning I  select some records & then i am clicking save button but I am getting blank page after click save button. vf page action attribute onload not working in lightning but I am executing save button from classic it works properly. In google chrome working properly in lightning & classic side both. But in mozilla firefox 66.0b5 (32-bit) & (64-bit) not working.
  • Please refer following action attribute onload code : 

public PageReference createStandOpportunities()

    {

Set<String> numberSet = ParserHelper.getNumberSet();

List<Opportunity> insertOppList = getOpportunityList(numberSet);

        if(insertOppList.size() > 0){

          createOpportunities(insertOppList);           

        }

}

private List<Opportunity> getOpportunityList(Set<String> numberSet){

List<Opportunity> insertOppList = new List<Opportunity>();

for(String eachNumber : numberSet){              

                    Opportunity newOpp = new Opportunity();

                    newOpp.Name = 'Opp-'+eachNumber;                   

                    newOpp.Posted_Date__c = Date.today();

                    newOpp.Data_Id = eachNumber;

                    newOpp.StageName = 'Prospecting';

                    newOpp.CloseDate = Date.newInstance(2080, 1,1);

                    insertOppList.add(newOpp);               

            }

return insertOppList;

}

 private void createOpportunities(List<Opportunity> insertOppList){

try{

            if(!insertOppList.isEmpty()){

               insert insertOppList;

                System.debug('Opportunity inserted.....');

            }             

        }catch(Exception ex){

            System.debug('Ex = '+ex.getMessage()+ ' : '+ex.getLineNumber());

        }

}

 
1 件の回答
  1. 2019年2月6日 10:59
           My Redirect code

            PageReference pageRef = new PageReference('/lightning/o/'+SOBJECT_TYPE_NAME+'/list?filterName=All');

            pageRef.setRedirect(true);   

            return pageRef;
0/9000
({

    doInit : function(component, event, helper) {

        

         /* Step 1*/

        var action=component.get('c.getContact');

        

        

        /*Optional*/  /* Step 1*/

        action.setParams({

            accountId : componenet.get

        });

        

         /* Step 4*/

        action.setCallback(this, function(response){

            var  responseValue =  response.getReturnValue();

            console.log('responseValue', responseValue);

            component.set('v.contactList',responseValue);

        },'SUCCESS');

        

         /* Step 3*/

        $A.enqueueAction(action,false);

    },

    doRedirect: function(component, event, helper){

        var events=event.getSource();

        var id=eventSource.get('v.name');

        alert(id);

    }

})

<aura:component controller="ContactList2"     

                implements="force:hasRecordId, flexipage:availableForAllPageTypes">

    <aura:attribute name="contactList" type="Contact[]"/>

    

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

     {!v.recordId}

    <div class="slds-p-around_xx-small">

    <aura:iteration items="{!v.contactList}" var="con">

        <lightning:card title="{!con.LastName}" footer="{!con.Email}" iconName="standard:contact">

            <aura:set attribute="actions">

                <lightning:button  name ="{!con.ID}" label="View Details" variant="brand" onclick="{!c.doRedirect}"/>

            </aura:set>

            <div class="slds-p-horizontal_xxx-small">

        {!con.FirstName} &nbsp;{!con.LastName} <br/>

        {!con.Email}  {!con.Phone}

                </div>

            </lightning:card>

    </aura:iteration>

    </div>

</aura:component>
4 件の回答
  1. 2021年7月19日 4:25
    Hi Hemant,

    Please compare your code with 

    /*Optional*/ /* Step 1*/

    action.setParams({

    accountId : component.get('v.recordId')

    });

    if you need any assistanse, Please let me know!!

    Kindly mark my solution as the best answer if it helps you.

    Thanks

    Mukesh 
0/9000

Is there something I can add to my visualforce code to hide the Upload Files button. I made the relate list read only but that did not do anything #Visualforce  #Lightning Experience 

7 件の回答
  1. 7月10日 7:20

    If you have Files Related List on your page in Lightning Experience, then Upload File Button is governed by user permissions and not Visualforce. Having your Related List in ReadOnly mode will not hide this button. You might need to check for file upload permission, Page Layout, or think about custom implementation. If you have Files Related List on your page in Lightning Experience, then Upload File Button is governed by user permissions and not Visualforce. Having your Related List in ReadOnly mode will not hide this button. You might need to check for file upload permission, Page Layout, or think about custom implementation.  walmartgiftcard-balance com 

0/9000
How to make a group of button act as checkbox functionality with the changes in button color.
2 件の回答
0/9000