How to Send Filtered Data from an External List to a Data View Web part of a Form Page?


When we develop Custom Form Page, on various occasions we need to retrieve Form Field Data from a SharePoint List or another External List.  In this example,  I am going to show how you can obtain data from an External List and send those data to your form fields while loading a New Form page.

Keep in your mind that in SharePoint 2010, when we create a new Form from SP Designer 2010, we get a Data View Web Part for the Form Fields.

First, let us create a custom Form page (which is a Web Part page) from the SP Designer 2010. Then, create parameters for fields which we need to get the data from the external list. To insert parameters in SP Designer 2010, Select Parameters from the Ribbon->Options. You should see the following window:

image

Now, click on “New Parameter”. For my requirements, I have created four new parameters for “ID”, “Name”, “Email” and “Phone”. Give any name for the Parameter name and Choose none for Parameter Source and none for Default Value. Click Ok.  Save your page.

image

Then, open that page in your Web Page and go to Site Actions->Edit Page. Now, you will see the web part zones where you can add a new web part. Click on “Add a Web Part” and choose your desired External List from the pop up window. Click “Add”. After adding the external list web part, select from the top right corner where you will get similar to the following window:

image

Choose Connections->Send Row of Data To. Here, “Request For Change” is the web part where I want to send the values.

image

Choose, “Get Parameters From” from Connection Type. Then select the tab “Configure Connection”.

image

Click Finish. Now, with this setting, I can only pass one value as a parameter to my consumer web part. This is a shortcoming of using web front end to create web part connection. If we want to send another, we cannot do so as we get the following window where there is no option for inserting additional fields.

image

To get rid of this situation, let us switch back to SP Designer 2010 and open the Custom New Form page in Advanced Edit mode. Here, you will notice that the External List which we added is being shown as “XSLTListViewWebPart”. Select the web part and click on “Manage Connections”. You will get like the following window:

image

Notice that our earlier connection which we created from the Web Front end is already there. Click on “Modify”.

image

You can now see the details of this web part connection (Source, Target, Action). Select “Send Row of Data To”.

image

Now, select “Connect to a Web part on this page”. Click “Next”.

image

Here, you can see the Target Web part and Target Action. Choose Target action “Get Parameters From”.

image

Here is the thing; you can now map multiple fields with multiple parameters that you created before.  For my case:

Columns in eBusinessInfo (External List)            Inputs to Request For Change (Consumer Web Part)

Email                                                                    paramEmail

ID                                                                         paramID

Work_Phone                                                        paramPhone

Full Name                                                             paramName

After mapping all the fields, click Next-> Finish. Now, my web part connection between the external list and form Data View Web Part is complete. But, yet I cannot use the values directly as a parameter. To do so, I need to modify my required Fields (SharePoint:FormField) and convert those as “TextBox” to use the parameter.

For example: For “Name” field, I have got the following form field.

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

 

Convert the above form field as:

<asp:TextBox runat="server" id="ff3{$Pos}"  Text="{$paramName}" ReadOnly="True" __designer:bind="{ddwrt:DataBind('i',concat('ff3',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Full_x0020_Name')}"/>

 

Important thing to note: Remove “ControlMode” and “FieldName” property and Change “Value” to “Text” and “ValueChanged” to “TextChanged” inside _designer: bind property.  As I want the Name to be read only , that’s why I kept ReadOnly=”True”.

Convert the other three fields in the same way and then preview your Form Page. I forgot one thing to mention here; of course, you don’t want to show up your External list in your New Form page. To do so, go to the property of the External List Web part and set “Hidden=True”. Now, if you browse your page in preview mode, you will see the values got populated in your Data View Web Part of your new Form Page.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s