Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

Dataformwebpart based custom form - Have got the attachment field to show/work - but attachment does NOT save on submit

$
0
0

My requirement is to have a custom form for a list (enabled for attachments) to show and save the attachment field as a form input.Although I've been able to show the field but I'm unable to get it to save.

As other blogs and threads point out this functionality is not supported by default/or is possible by workarounds, I used the following MS KB article to change the code in sharepoint designer.

KB Article 953271 Microsoft Support

As per the article,  I made the following changes to the code

1. Inserted the following code within the <xsl:template name="dvt_1">

            <div>
                    <span id="part1">
                        <table border="0" width="100%">
                            <xsl:call-template name="dvt_1.rowinsert">
                                <xsl:with-param name="IsInsertMode">
                                    <xsl:if test="$dvt_1_form_insertmode = '1'">1</xsl:if>
                                </xsl:with-param>
                            </xsl:call-template>
                        </table>
                    </span>   
                    <SharePoint:AttachmentUpload runat="server" ControlMode="New"/>
                    <SharePoint:ItemHiddenVersion runat="server" ControlMode="New"/>
                 </div>
2. Created form element as a new row in the form

                       <tr id="idAttachmentsRow">
                                <td nowrap="true" valign="top" class="ms-formlabel" width="20%">
                                    <SharePoint:FieldLabel ControlMode="New" FieldName="Attachments" runat="server"/>
                                </td>
                                <td valign="top" class="ms-formbody" width="80%">
                                     <SharePoint:FormField  runat="server"  ID="ff32{$Pos}"  ControlMode="New"  FieldName="Attachments" __designer:bind="{ddwrt:DataBind('i',concat('ff32',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Attachments')}"  />
                                     <SharePoint:FieldDescription runat="server" id="ff32Desc{$Pos}" FieldName="Attachments" ControlMode="Edit" /> 
                                       <script>
                                            var elm = document.getElementById(&quot;idAttachmentsTable&quot;);
                                            if (elm == null || elm.rows.length == 0)
                                            document.getElementById(&quot;idAttachmentsRow&quot;).style.display=&apos;none&apos;;
                                       </script>
                                  </td>
                             </tr>

3. In a separate row, I am simply calling the javascript function that is usually called from the ribbon

<a href="javascript:UploadAttachment()">Attach File</a> <br/>

Now, doing so, the form displays the attachment field on clocking the 'Attach File' link, allows the user to browse and select file(s) and on clicking 'Ok' shows the list of files with their paths in the main form row (Code in step 2)

Problem: On submitting the form, the list item saves correctly but for the attachment field. Saving an attachment via a standard sharepoint NewForm.aspx works fine.

Any ideas/directions/solutions will be of much help.


Viewing all articles
Browse latest Browse all 11508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>