javaniceday.com

  • Home
  • AboutAbout me
  • Subscribe
  • SalesforceSalesforce related content
  • Node JSNodejs related content
  • JavaJava related content
  • Electric Vehicles
  • Autos Eléctricos
  • Estaciones de carga UTE
  • Mapa cargadores autos eléctricos en Uruguay
  • Dealing With Customers

    August 26th, 2017

    50% is your product an 50% is your support

    Jozsef Torsan's avatarJozsef Torsan

    I receive many emails from customers. I’m happy that more than 90% of these emails are about feature requests and not bugs. A small part of the emails is “how to” questions and an even smaller part is about reporting bugs. Since the last year’s October launch only 3 customers contacted me with bugs. 2 of them had ran into the emoji issue and one of them contacted me just last week with an issue about having an incorrect size of the Add Bookmark window in Opera. Fortunately it was an easy fix and I was I able to fix it by the next day. The truth is Opera was not among the browsers (Chrome, Firefox, IE, Edge, Mac Safari) I tested — shame on me. Anyway it’s worth to check the browser statistics and the trends on this page. It can give you a good hint when you plan the…

    View original post 586 more words

    Share this:

    • Click to share on X (Opens in new window) X
    • Click to share on LinkedIn (Opens in new window) LinkedIn
    • Click to share on Reddit (Opens in new window) Reddit
    • Click to email a link to a friend (Opens in new window) Email
    Like Loading…
  • Java client for advanced pdf conversion using a Salesforce org

    August 25th, 2017

    All we know renderAs=”pdf”. nThe good news is now Salesforce has an advanced pdf converter:

    renderAs=”advanced_pdf”

    <apex:page sidebar="false" showHeader="false" renderAs="advanced_pdf">
  <html lang="en-US" >
    <head>
      <meta charset="UTF-8" />
    </head>
    <body>
      <h1>Hello, world!</h1>
    </body>
  </html>
</apex:page>

    Still this functionality is a pilot what It means that you need to create a case and someone from support will activate It in your org.

    “Advanced PDF renders Visualforce pages as PDF files with broader support for modern HTML standards, such as CSS3, JavaScript, and HTML5. This change applies to both Lightning Experience and Salesforce Classic.” Read more

    In some projects I had to convert html to pdf. Some solutions like iText did not work well in complex html so I needed a better solution. One of them is take advantage of advanced_pdf rendering from Salesforce so with a simple web service should be easy.

    This Apex class exposes a RESTful webservice that receives an html string an return a pdf as base64

    @RestResource(urlMapping='/htmltopdf')
global class HtmlToPdf {
  @HttpPost
  global static PdfResponse convertToPdf(String html) {
    browser.RenderRequest request = new browser.RenderRequest();
    request.setPageContent(html);
    Blob blobVal = browser.Browser.renderToPdf(request);
    PdfResponse resp = new PdfResponse();
    resp.base64Content = EncodingUtil.base64Encode(blobVal);
    return resp;
}

  global class PdfResponse {
    String base64Content;
  }
}

    Then all you need is this Java client to consume that web service.

    Important: by default remote css, images and any other resource won’t work. I recommend you upload
    all in a static resource and do references using relative path.

    If you want to use remote resources you must create a Remote Setting in your org and of course pdf conversion will be slower.

    See the full example in my Github account https://github.com/andrescanavesi/salesforce-pdf-converter

     

    Share this:

    • Click to share on X (Opens in new window) X
    • Click to share on LinkedIn (Opens in new window) LinkedIn
    • Click to share on Reddit (Opens in new window) Reddit
    • Click to email a link to a friend (Opens in new window) Email
    Like Loading…
  • Define environment variables in Tomcat

    August 25th, 2017

    Sometimes you want to change the behavior of your code without recompiling / deploying.  A way to do this is defining environment variables that you can change at any time. A typical use case is for database connection properties (username, password, port, etc).

    In your Tomcat home create this file $TOMCAT_HOME/bin/setenv.sh and define variables like this:

    export VAR1=my_var1_value
    export VAR2=my_var2_value
    

    Give execution permission

    chmod 755 setenv.sh
    

    In Windows define variables like this:

    set VAR1=my_var_value
    

    After saving the file you must reboot Tomcat.

    In your code you get the environment variable this way:

    //value will be null if VAR1 does not exist
    String value = System.getenv("VAR1");
    

    Share this:

    • Click to share on X (Opens in new window) X
    • Click to share on LinkedIn (Opens in new window) LinkedIn
    • Click to share on Reddit (Opens in new window) Reddit
    • Click to email a link to a friend (Opens in new window) Email
    Like Loading…
  • Salesforce client for an Apex RESTful web service

    May 8th, 2017

    An example about how to consume a Salesforce api rest, in particular:

    /services/apexrest/

    The example shows how to authenticate using username and password to get the access token and then how to do a request to this Salesforce web service:

    @RestResource(urlMapping='/hellorest')
    global class HelloRest {
    
        @HttpPost
        global static String echo(String name) {
            String echo = 'Hi, '+name;
            System.debug('Echo: '+echo);
            return echo;
        }
    }
    

    See the code from Github https://github.com/andrescanavesi/salesforce-apex-rest

    Photo by Franck V. on Unsplash

    Share this:

    • Click to share on X (Opens in new window) X
    • Click to share on LinkedIn (Opens in new window) LinkedIn
    • Click to share on Reddit (Opens in new window) Reddit
    • Click to email a link to a friend (Opens in new window) Email
    Like Loading…
←Previous Page
1 … 23 24 25

  • LinkedIn
  • GitHub
  • WordPress

Privacy PolicyTerms of Use

Website Powered by WordPress.com.

  • Subscribe Subscribed
    • javaniceday.com
    • Already have a WordPress.com account? Log in now.
    • javaniceday.com
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
%d