0

I've been set the task of building a form that should be accessible as an edit form associated with a list, but should edit fields across several lists. The data model is:

List with Item info (MAIN) -------> List with multiple files stored per item (DOWNLOADS)
E.g.
   (1) Name:       Bob
       Comments:   Hello
       ID:         1
       FirstCheck: A.xlsx   -----> ID: Arbitrary; Title: 1_FirstCheck; File: A.xlsx
       FollowUp:   B.xlsx   -----> ID: Arbitrary; Title: 1_FirstCheck; File: B.xlsx

The form I need to build needs to be an edit form for an item in Downloads but allow for editing the Comments field in Main.

Currently, I've cloned and messed with the Edit Form for Downloads, deleting unneeded fields etc. I've also identified that fields in general are specified by an XML tag along these lines in Sharepoint Designer:

<SharePoint:FormField 
    runat="server" 
    id="ff4{$Pos}" 
    ControlMode="Display" 
    FieldName="SemanticID" 
    __designer:bind="{ddwrt:DataBind('u',concat('ff4',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@SemanticID')}"
/>

I've tried creating a new line elsewhere along the lines of:

<SharePoint:FormField 
    runat="server" 
    ListId="{1D7B7810-688A-4552-9EB1-48DEF6F7B620}" 
    id="ff40{$Pos}" 
    ControlMode="Display" 
    FieldName="Title" 
    __designer:bind="{ddwrt:DataBind('u',concat('ff40',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}" 
    ItemId="1" 
/>

As a starting point to display the contents of Item 1 for Main (list ID {1D7B7810-688A-4552-9EB1-48DEF6F7B620}), but I just get an uninformative error when displaying the page.

Can anyone suggest what I need to do to firstly just get/edit the contents of a specific ID using a Sharepoint:FormField control, and secondly, how I might be able to assign an ItemID to edit in Main based on the Title field in `Downloads?

I'd also be interested in knowing how to include JavaScript in a form, if it's possible.

I should point out that my Dev environment is Sharepoint Designer; for whatever reason (possibly because we're using a hosted version of Sharepoint?) I can't open the site in Visual Studio.

0

Whilst there might be built in functionality to accomplish this, I ended up doing the following:

  1. Inserted a second web-part into the form - in particular an HTML Form WebPart, which allows for arbitrary HTML tags, including JavaScript, to execute.
  2. Wrote a wrapper around the MS Save buttons to hide them and display another button in their place styled more or less the same. The button is still part of the DOM, so it can still be clicked, but now only by code.
  3. Wrote JavaScript to retrieve the appropriate item join from Main, and then added lines to the table with appropriate controls.
  4. When the user clicks save, instead of simply doing the MS code, it executes my code to send the new values back to Main first. Then finds the save button again and fires a click event at it, allowing the rest of the form to behave normally.

There's a few limitations with this approach. Most obviously is that it's not exactly the "SharePoint" way of doing things (which I'd still like to know), that there might be quirks of versions that make my mechanisms for finding tables, save buttons, etc less reliable in the future, and that I'm limited to standard HTML controls and have no data validation to speak of (thankfully there's very little for me to worry about in my application, but could be an issue for others). But it does work.

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.