• Mélanie Texereau
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 6
    Replies
Hi,

I would create a post in Chatter with a PDF of my quote, in action for SF1. My code works fine in Salesforce 1 but in Salesforce, when I refresh my details page of my quote, a new post with my PDF is created. Each time I refreshed my page, a new post is created. Can you help me ?

This is my class :
public with sharing class VFC38_SF1_DevisPDF {

	public DevisCommande__c devis {get;set;}

	public VFC38_SF1_DevisPDF(ApexPages.StandardController sc) {
		
		devis = (DevisCommande__c) sc.getRecord();
	}

	public void redirect(){

		PageReference pageRef = new PageReference('/apex/VFP16DevisPDF?id=' + devis.Id);

		String stringToBlob = Test.isRunningTest() ? 'test' : EncodingUtil.base64Encode(pageRef.getContent());
        system.debug('### TEST 2');

        String folderId = [SELECT Id FROM Folder WHERE Name = 'Devis'].Id;
        FeedItem post = new FeedItem();

        /* Create a document */
        Document d = new Document();
        d.Name = 'Devis ' + String.valueOf(DateTime.now().format('dd/MM/yyyy hh:mm:ss'));
        d.ContentType = 'application/pdf';
        d.Type = 'pdf';
        d.FolderId = folderId;
        d.Body = EncodingUtil.base64Decode(stringToBlob);

         /* Create a post chatter */
        post.ParentId = devis.Id;
        post.Type = 'ContentPost';
        post.ContentData = d.Body;
        post.ContentFileName = d.Name+'.pdf';
    
        insert post;
	}
}

This is my VF page : 
<apex:page docType="html-5.0" sidebar="false" showheader="false" standardController="DevisCommande__c" extensions="VFC38_SF1_DevisPDF" standardStyleSheets="false" action="{!redirect}">
   
</apex:page>

Thanks for your help.

Hi,

I have a PDF Quote which is a VisualForce Page, and I would insert a "terms and conditions" document (is a PDF file) in my Visualforce page.

It is possible ? I try to use :

- <apex:image>
- <apex:iframe>
- <object>

and it doesn't work...

Do you have any ideas ?
Hi,

I would create a post in Chatter with a PDF of my quote, in action for SF1. My code works fine in Salesforce 1 but in Salesforce, when I refresh my details page of my quote, a new post with my PDF is created. Each time I refreshed my page, a new post is created. Can you help me ?

This is my class :
public with sharing class VFC38_SF1_DevisPDF {

	public DevisCommande__c devis {get;set;}

	public VFC38_SF1_DevisPDF(ApexPages.StandardController sc) {
		
		devis = (DevisCommande__c) sc.getRecord();
	}

	public void redirect(){

		PageReference pageRef = new PageReference('/apex/VFP16DevisPDF?id=' + devis.Id);

		String stringToBlob = Test.isRunningTest() ? 'test' : EncodingUtil.base64Encode(pageRef.getContent());
        system.debug('### TEST 2');

        String folderId = [SELECT Id FROM Folder WHERE Name = 'Devis'].Id;
        FeedItem post = new FeedItem();

        /* Create a document */
        Document d = new Document();
        d.Name = 'Devis ' + String.valueOf(DateTime.now().format('dd/MM/yyyy hh:mm:ss'));
        d.ContentType = 'application/pdf';
        d.Type = 'pdf';
        d.FolderId = folderId;
        d.Body = EncodingUtil.base64Decode(stringToBlob);

         /* Create a post chatter */
        post.ParentId = devis.Id;
        post.Type = 'ContentPost';
        post.ContentData = d.Body;
        post.ContentFileName = d.Name+'.pdf';
    
        insert post;
	}
}

This is my VF page : 
<apex:page docType="html-5.0" sidebar="false" showheader="false" standardController="DevisCommande__c" extensions="VFC38_SF1_DevisPDF" standardStyleSheets="false" action="{!redirect}">
   
</apex:page>

Thanks for your help.

Hi,

I have a PDF Quote which is a VisualForce Page, and I would insert a "terms and conditions" document (is a PDF file) in my Visualforce page.

It is possible ? I try to use :

- <apex:image>
- <apex:iframe>
- <object>

and it doesn't work...

Do you have any ideas ?