[SalesForce] How to call the standard New Note or New Attachment pages

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?

Best Answer

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.

Related Topic