function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RRRizeRRRize 

Notes & Attachments Visualforce page - Good or bad idea?

I've created a custom object.  I'd like to enable the user to attach documents to the form before they save it.  The reason for this is that the user MUST submit this form to another department (by checking a checkbox which triggers the submission workflow).  As it stands right now, in order to attach a document to the form, the user has to do the following:

 

1. Fill out form

2. Save form

3. Attach document

4. Edit form

5. Check SUBMIT checkbox (to trigger submission of the form)

6 Save form again

 

Not very intuitive at all.  I would like for them to be able to do the following:

 

1. Fill out form

2. Attach document

3. Check Submit checkbox

4. Save

 

I was thinking that the best way to approach this would be to create a VF page that would provide the Notes & Atachments functionality.  They would launch that page from a button in the form. So...


I was wondering:

 

1. If this is even possible

2. Is this is a good solution?

3. Can you recommend a better solution?

4. If it is possible, and a good solution, can you describe what seps I should follow to achieve it?

 

Thanks in advance.

Afzal MohammadAfzal Mohammad

Yes, it is possible.

 

Here is what I have compiled for you.

 

Extension class (addcntdocExt)

 

public class addcntdocExt {
    public Contact contact {set; get;}
    public addcntdocExt(ApexPages.StandardController controller) {
        this.contact = (Contact)controller.getRecord();
    }

    public PageReference save(){
        upsert contact;
        PageReference addDoc = new PageReference('/p/attach/NoteAttach?pid='+ contact.Id + '&retURL=/apex/apex/addcntdoc?Id=' + contact.Id);
        addDoc.setRedirect(true);
        return addDoc;
    }
}

 

 

Visual Force Page (addcntdoc)

 

 

<apex:page standardController="Contact" extensions="addcntdocExt">
<apex:form >
    <apex:pageBlock title="Create New Contact" mode="edit">
        <apex:pageBlockButtons >
            <apex:commandButton value="Create Contact" action="{!save}"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection collapsible="false" columns="1" id="cntForm" >
            <apex:inputField value="{!contact.FirstName}"/>
            <apex:inputField value="{!contact.LastName}"/>
            <apex:inputField value="{!contact.Title}"/>
            <apex:inputField value="{!contact.Email}"/>
            <apex:inputField value="{!contact.Phone}"/>
            <apex:inputField value="{!contact.Submit__c}" rendered="{!IF($CurrentPage.Parameters.Id!=null,true,false)}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>    
</apex:page>

 

 

Hope that helps.

 

Afzal