You need to sign in to do that
Don't have an account?
jaredbaker
XFDF Creation, Problem making button
UPDATE:
I've gotten it working, made a button, it is attaching the file properly and everything. But now, when I go to open the .xfdf file, it just downloads another copy, or get stuck in a loop without ever opening the form. Now what!?
I am trying to create a button that will call a Visualforce page which calls the below code to make a .xfdf file. For whatever reason, it won't let me make a button. What am I doing wrong? Any help is HUGELY appreciated! Thanks in advance!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | public with sharing class CreateIO { DateTime nowDT=System.now(); String formatted=nowDT.format('dd_MM_yyyy'); private String getXmlString(JJSale__c a) { String s = '<?xml version="1.0" encoding="UTF-8"?>' + '<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">' + '<f href="https://cs9.salesforce.com/resource/1304098375000/IO_JJ"/>' + '<fields>' + '<field name="Acct Rep"><value>' + a.CreatedBy.Name + '</value></field>' + '<field name="Ad Cost"><value>' + a.Ad_Price__c + '</value></field>' + '<field name="Address"><value>' + a.Organization__r.BillingStreet + '</value></field>' + '<field name="Advertiser"><value>' + a.Organization__c + '</value></field>' + '<field name="Bill to"><value>x</value></field>' + '<field name="City"><value>' + a.Organization__r.BillingCity + '</value></field>' + '<field name="Contact"><value>' + a.Contact__c + '</value></field>' + '<field name="Date"><value>' + formatted + '</value></field>' + '<field name="Email"><value>' + a.Contact__r.Email + '</value></field>' + '<field name="Fax"><value>' + a.Contact__r.Fax + '</value></field>' + '<field name="INSERTION DATES AND NOTES 1"><value>' + a.Journal_Issue__c + '</value></field>' + '<field name="INSERTION DATES AND NOTES 2"><value>' + a.Page_Requested__c + ',' + a.Insertion_Notes__c + '</value></field>' + '<field name="Phone"><value>' + a.Contact__r.Phone + '</value></field>' + '<field name="State"><value>' + a.Organization__r.BillingState + '</value></field>' + '<field name="Todays Date"><value>' + formatted + '</value></field>' + '<field name="Zip"><value>' + a.Organization__r.BillingPostalCode + '</value></field>' + '</fields><ids original="CB86FA72BFC7A2744D5052A67D1686EE" modified="C0A949601A5BB74AB94C1DAA08D65D2F"/>' + '</xfdf>'; return s; } public PageReference XFDFInit() { JJSale__c a = [SELECT Id, CreatedBy.Name, Ad_Price__c, Organization__r.BillingStreet, Organization__c, Organization__r.BillingCity, Contact__c, Contact__r.Email, Contact__r.Fax, Journal_Issue__c, Page_Requested__c, Insertion_Notes__c, Contact__r.Phone, Organization__r.BillingState, Organization__r.BillingPostalCode FROM JJSale__c WHERE id = :ApexPages.currentPage().getParameters().get('id')]; String xmlContent = getXmlString(a); Attachment attachment = new Attachment(); attachment.Body = Blob.valueof(xmlContent); attachment.Name = a.Organization__c + formatted + '.XFDF'; attachment.ParentId = a.Id; insert attachment; PageReference salePage = new PageReference('/' + a.id); salePage.setRedirect(true); return salePage; } } |
<apex:page showHeader="true" controller="CreateIO" action="{!XFDFInit}"> </apex:page>
I actually had tried that before you commented, but was getting the same error. I found my problem and fixed it (instead of calling a visualforce page with my button, I just needed to make a button that links to a url - /apex/CreateIO?id={!JJSale__c.Id} - worked like a charm.)...not to solve the other issue...Thank you VERY MUCH, btw, for your help! Really appreciate having someone who knows what they're doing looking over my sholder.
All Answers
Jared,
Try this Visualforce:
<apex:page showHeader="true" controller="CreateIO">
<apex:form>
<apex:commandButton action="{!XFDFInit}">
</apex:form>
</apex:page>
Forgot to add Value, try this. Typing this freehand. :)
<apex:page showHeader="true" controller="CreateIO">
<apex:form>
<apex:commandButton action="{!XFDFInit}" value="Create XFD"/>
</apex:form>
</apex:page>
I actually had tried that before you commented, but was getting the same error. I found my problem and fixed it (instead of calling a visualforce page with my button, I just needed to make a button that links to a url - /apex/CreateIO?id={!JJSale__c.Id} - worked like a charm.)...not to solve the other issue...Thank you VERY MUCH, btw, for your help! Really appreciate having someone who knows what they're doing looking over my sholder.
Cool.
I guess I misread your requirement. You needed a button to invoke your Visualforce page initially, not add a button to a Visulafore Page.
Glad you got it to work.
Yup. I had misunderstood how creating the button worked, so no worries.
Any suggestions with the new problem? I try to open the .xfdf created, but instead of pulling it up on top of the referenced .pdf, it just downloads a new copy of the .xfdf and/or throws up an error (a different one on every machine I've tried thus far).
can anyone please explain me how do you have created this static resource. '<f href="https://cs9.salesforce.com/resource/1304098375000/IO_JJ"/>' +
thanks in advance.