3

I have a requirement where I need to provide New Note and New Attachment buttons on a Visualforce page and cannot use the standard related list. Every method I've tried so far has led to an error:

  • Using URLFOR($Action.Note.New), but that $Action does not exist.
  • A direct link to /002/e?parent_id=[record id], but that gives a "Data Not Available" error message (tried with and without confirmation token)
  • Using an <apex:commandButton> where the following controller method provides a redirect also yields "Data Not Available":

    public PageReference NewNote(){
      PageReference redirect = new PageReference('/002/e');
      redirect.getParameters().put('parent_id', sfObject.Id);
      redirect.getParameters().put('retURL', this.ReturnUrl);
      redirect.setRedirect(true);
      return redirect;
    }
    

Is there any way to invoke the pages for New Note and New Attachments without using the standard related list?

1

For the Note case, /002/e?parent_id=[record id] doesn't work for me with the 18 digit id (Data Not Available) but does with the 15 digit id.

For the Attachment case, /p/attach/NoteAttach?pid=[record id]&retURL=... works, though as an even less "documented" URL pattern you may not want to risk it. 15 digit id again.

  • I'll have to try out the 15 digit id; that never even occurred to since I thought they were interchangeable. – Mike Chale Apr 3 '14 at 14:47
  • So both of these work; thank you. I'm going to give it a day or two to see if there is a more official or sanctioned method before marking it as the answer, though. – Mike Chale Apr 3 '14 at 15:10
  • Makes sense. If there is a cleaner way I'll change my code to use that too. – Keith C Apr 3 '14 at 15:13
  • Salesforce support suggested (and linked to) this answer. "I would like to inform as the Note object is not supported for $Action variable. Please use the sample code mentioned on the link below: salesforce.stackexchange.com/a/31766/142 This is only the way by which we can create the Note record." – Mike Chale Apr 4 '14 at 13:34
  • does this still work (the 15 char parentId) for Notes? I can't make it work - Data Not Available – cropredy Jan 28 '16 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.