You need to sign in to do that
Don't have an account?
Need to Upload a file while creating a record on VF
Hi All,
I have a custom object called Leap_Weekly_Curriculum__c and I need a VF page that will help me input values into it and also upload a file which should get added to the attachments related list of the same record. Please help.
I have a custom object called Leap_Weekly_Curriculum__c and I need a VF page that will help me input values into it and also upload a file which should get added to the attachments related list of the same record. Please help.
Visualforce Page: Apex Class:
Thanks for responding.
But I'm getting this error now : [Error] Error: Compile Error: Invalid type: attachment at line 33 column 41
Please help out!
Thanks,
Avinash
If you re still getting the error message then just delete that error line and retype the same line again(don't copy and paste). You will also get another error message in the Apex.currentPage(); again repeat the same, delete that error line and retype once again.To identify the sapace between the text in the code, open the apex class in the developer console, it will identify the space inbetween letters and show in red dot color.
This is what I'm getting now.. guess it isn't saving the curriculum record first up.
Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Parent]: [Parent]
Error is in expression '{!uploadFile}' in component <apex:commandButton> in page leapcurriculum: Class.PropUpload.UploadFile: line 35, column 1
An unexpected error has occurred. Your development organization has been notified.
Now I tried changing this myAttachment.Parent.Id = recId; and this is the error I'm getting
Attempt to de-reference a null object
Error is in expression '{!uploadFile}' in component <apex:commandButton> in page leapcurriculum: Class.PropUpload.UploadFile: line 33, column 1
An unexpected error has occurred. Your development organization has been notified.