tag:blogger.com,1999:blog-1935655503299435627.post6389657853932163675..comments2023-03-29T20:31:21.038+05:30Comments on Force.com, Visualforce, Apex, Triggers, Sites : Trekbin Technologies: Visualforce File Upload - for Any SObjectTrekbin Technologieshttp://www.blogger.com/profile/08235678279956052118noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-1935655503299435627.post-78810537288075375342019-10-18T00:17:46.963+05:302019-10-18T00:17:46.963+05:30I am able to create pdf under notes and atachments...I am able to create pdf under notes and atachments but its creating multiple attachments. Need Help.<br /><br />VF Page: (DecisionLetter)-- Data is on this page<br /><br />-----------------------<br />VF Page: (DecisionLetter_V2)<br /><br /><br /><br />-------------------------------------<br />Class:<br />public class attachPDFToContact {<br /> public string recId {set;get;}<br /> <br /> //constructor<br /> public attachPDFToContact(ApexPages.StandardController standardPageController) {<br /> recId = standardPageController.getId();<br /> }<br /> <br /> //method called from the Visualforce's action attribute<br /> public void attachPDF() {<br /> Blob pdfBlob;<br /> try {<br /> PageReference pdfPage = Page.DecisionLetter_v2;<br /> pdfPage.getParameters().put('id',recId);<br /> pdfBlob = pdfPage.getContent();<br /> }catch(exception e){<br /> pdfBlob = blob.valueOf('this is from excetion '+e.getMessage());<br /> }<br /> Attachment attach = new Attachment(ParentId = ApexPages.currentPage().getParameters().get('id'), Name = 'DecisionLetter - '+ system.Now() + '.pdf', body = pdfBlob);<br /> insert attach;<br /> }<br />}Ankit Arorahttps://www.blogger.com/profile/05935004453543778435noreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-19387995820732334832018-12-14T16:38:41.030+05:302018-12-14T16:38:41.030+05:30want to create a new lead record and attachment in...want to create a new lead record and attachment in one go.but not getting how to ralated those both things<br />vf page:<br /><br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /><br />myWeb2LeadExtension:<br />public class myWeb2LeadExtension {<br /><br /> private final Lead weblead;<br /> <br /> <br /> public myWeb2LeadExtension(ApexPages.StandardController<br /> stdController) {<br /> weblead = (Lead)stdController.getRecord();<br /> <br /> <br /> }<br /> <br /> public PageReference saveLead() {<br /> try {<br /> <br /> insert(weblead);<br /> <br /> <br /> }<br /> catch(System.DMLException e) {<br /> ApexPages.addMessages(e);<br /> return null;<br /> }<br /> <br /> <br /> PageReference p = Page.ThankYou;<br /> p.setRedirect(true);<br /> return p;<br /> }<br /> <br /> <br /> <br />}<br />attachmentsample:<br />public class attachmentsample {<br /><br /> public String Leadid;<br /> public attachmentsample(ApexPages.StandardController controller) {<br /> String Leadid = System.currentPagereference().getParameters().get('id');<br /><br /> }<br /> Public Attachment myfile;<br /> Public Attachment getmyfile()<br /> {<br /> myfile = new Attachment();<br /> return myfile;<br /> }<br /> <br /> Public Pagereference Savedoc()<br /> {<br /> // String Leadid = System.currentPagereference().getParameters().get('id');<br /><br /> Attachment a = new Attachment(parentId = Leadid, name=myfile.name, body = myfile.body);<br /> <br /> /* insert the attachment */<br /> insert a;<br /> <br /> return NULL;<br /> } <br /><br />}<br />getting parentid missing exception.<br />anyone knows why i'm getting this problemAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-38121461530373674802017-03-07T15:52:09.779+05:302017-03-07T15:52:09.779+05:30add parent id like:
att.ParentId = '0016F00001...add parent id like:<br />att.ParentId = '0016F00001wlrGL'; // the record the file is attached to, then u wont get error<br />thanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-39747152562842485162017-03-06T21:43:58.068+05:302017-03-06T21:43:58.068+05:30Getting the following error: Error: Documents li...Getting the following error: Error: Documents line 27, column 30: The entity name must immediately follow the '&' in the entity reference <br />Error Error: The entity name must immediately follow the '&' in the entity reference.<br /><br />Line 27: if(fileBody != null && fileName != null) Does this need to be the name of my document in which I want to be shown?Anonymoushttps://www.blogger.com/profile/12509261333799161846noreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-79855400389756335622016-12-21T18:42:36.268+05:302016-12-21T18:42:36.268+05:30Hi,
I tried to implement this functionality insid...Hi,<br /><br />I tried to implement this functionality inside a form which has rerender/ oncomplete buttons and I am getting this error:<br />apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute. <br /><br />Can you pls suggest solution for this?<br /><br />Thanks<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-19605142320296302142016-08-25T13:05:33.145+05:302016-08-25T13:05:33.145+05:30Hai all,
I am creating a Visualforce page to uploa...Hai all,<br />I am creating a Visualforce page to upload photos and these photos are saved in the attachments object.How can i Upload Image(above 1MB to 10MB) Attachments to Salesforce using Javascript RemotingAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-7895112028599400942012-02-17T15:36:04.580+05:302012-02-17T15:36:04.580+05:30Thank you for the info. It sounds pretty user frie...Thank you for the info. It sounds pretty user friendly. I guess I’ll pick one up for fun. thank u<br /><br /><br /><a href="http://www.mdcovered.com/" rel="nofollow">ASC Coding</a>amroothahttps://www.blogger.com/profile/14435621748154936365noreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-42476319135091126492012-01-09T21:06:13.796+05:302012-01-09T21:06:13.796+05:30Hi, I got an issue on rendered the page with input...Hi, I got an issue on rendered the page with inputFile... Any suggestion?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-34663637314764706492011-12-02T01:33:52.152+05:302011-12-02T01:33:52.152+05:30Hi Srinivas,
I am having an issue with required ...Hi Srinivas,<br /><br /> I am having an issue with required field validation on a form along with upload file.But if the validation of form fails then it removes the file path.It confuses end users.How to fix this?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-90525799596516145892011-10-13T20:04:19.405+05:302011-10-13T20:04:19.405+05:30How can the user be notified if the attachment siz...How can the user be notified if the attachment size is too big? SF has file size limits of 5 MB.Kirillhttp://mainline.comnoreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-42422314516671605932011-07-07T10:46:19.053+05:302011-07-07T10:46:19.053+05:30i can't able to get the line you said.....
(ma...i can't able to get the line you said.....<br />(make the "myAttachment" variable belong to the controller, not just scoped within the upload function. Then the attachment remains as part of the controller until the controller finally runs save().)<br /><br /> could you please explain deep?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-23822750636186191902011-03-02T11:16:43.672+05:302011-03-02T11:16:43.672+05:30Srinivas,
I am trying to take Input File and upl...Srinivas, <br /><br />I am trying to take Input File and uploading .csv file.<br />Can I have the preview of the file which I imported.Charan Tejhttps://www.blogger.com/profile/09019338396431275946noreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-39586203244165201012010-10-06T06:05:22.396+05:302010-10-06T06:05:22.396+05:30Hi Srinivas,
Just wondering if you have any tips ...Hi Srinivas,<br /><br />Just wondering if you have any tips on how I could implement the upload to handle multiple documents in the same upload action.<br /><br />ImranAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-47753171583934366522010-09-29T00:58:08.807+05:302010-09-29T00:58:08.807+05:30is there any way you can store the file path from ...is there any way you can store the file path from where you are attaching this file?<br />Say, there is a custom URL field in which I want to store the source file path, can I fd that? I have tried this by all means but not able to achieve...thanks for your help!Nirmalhttps://www.blogger.com/profile/02211980107345001085noreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-28203662362005342202010-06-25T00:19:14.221+05:302010-06-25T00:19:14.221+05:30If you want to attach the uploads to a new, not ye...If you want to attach the uploads to a new, not yet extant, object, make the "myAttachment" variable belong to the controller, not just scoped within the upload function. Then the attachment remains as part of the controller until the controller finally runs save().<br /><br />Within your controller's save() function you do this:<br /><br />insert myNewRecord;<br />myAttachment.parentId = myNewRecord.Id<br />insert myAttachment;<br /><br /><br />So within save(), you're creating the new record of the object type related to the controller. Once you insert it, you have an idea. Now apply that ID to the attachment.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-28879017386816818692010-06-14T03:56:36.458+05:302010-06-14T03:56:36.458+05:30I think he was trying to attach a file to a new ob...I think he was trying to attach a file to a new object, which of course doesn't yet have an id. How can you get the id before you actually save the record?<br />-ErikAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-40843396329139676932010-05-25T08:37:58.619+05:302010-05-25T08:37:58.619+05:30The page has to be launched from a detail page but...The page has to be launched from a detail page button of an SObject like Contact or Some Custom Object. <br />In your case The Id value is missing, that is why the error.<br />You can pass the id in the URL and get it in the constructor also like this,<br />public VFFileUpload(ApexPages.StandardController ctlr) <br /> { <br /> recId = ApexPages.CurrentPage().getParameters().get('Id'); <br />'Hope this helps<br />-Srinivas.<br /> }Trekbin Technologieshttps://www.blogger.com/profile/08235678279956052118noreply@blogger.comtag:blogger.com,1999:blog-1935655503299435627.post-8913206178090661312010-05-23T05:11:45.944+05:302010-05-23T05:11:45.944+05:30Hi ,
I have this problem :
Apex script unhandl...Hi , <br /><br />I have this problem : <br /><br />Apex script unhandled exception by user/organization: 005A0000000SQvc/00DA0000000YfN2<br /><br />Visualforce Page: /apex/UploadAttachment<br /><br /><br /><br />caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [ParentId]: [ParentId]<br /><br />Class.VFFileUpload.UploadFile: line 15, column 5<br />External entry point<br /><br />Debug Log:Anonymousnoreply@blogger.com