locked
Customize NewForm.aspx for List RRS feed

  • Question

  • I need a checkbox field in insert site of sharepoint 2007 list. If this field is selected, some more fields should be displayed, else those fields should be hidden. With infopath 2007 function "Conditional Formatting" I can do it. But I don't want to use Infopath (Attachments can not be published in SharePoint). Is it possible with SharePoint Designer 2007 to do the similar design for insert new item. The "Conditional Formatting" in SPD works only for display site but not for new item site. Anyone has idea?
    Wednesday, September 28, 2011 8:05 AM

Answers

  • Hi Hulu,

    I've been trying to remember the specific process I used in a similar situation to make this work with the NewForm, including  going through old notes. In short, you will need a way to "pre-populate" the field in the NewForm that you want to use for the Conditional Formatting criteria.

    There are a number of ways to do this, most commonly using JavaScript, if you're proficient in it. I'm not, so I had to find another procedure.

    In my situation, the data was already in another list, and I passed it into the NewForm by appending the field to the URL that opened the NewForm. You could also set up an intro page that users see before opening the NewForm, and do the same thing. There they would make the selection for the data that will get pre-populated. To pass a Query String Variable to the NewForm, use an ampersand (formatted as &) at the end of the URL.

    In the NewForm itself, you will then need to populate the appropriate field with the info from the URL. The following link was the one that was most helpful to me, but not all of it applies and it took a bit of time tinkering before I was successful.

    http://geekswithblogs.net/SoYouKnow/archive/2009/10/29/setting-sharepoint-form-fields-using-query-string-variables-without-using.aspx

    Good luck,

    Eric

    • Marked as answer by Wayne Fan Thursday, October 6, 2011 6:52 AM
    Thursday, September 29, 2011 9:05 PM

All replies

  • It's limited what you can do through the SPD UI, as it's only ment to maintain a site, not further develop it. You'll have to create a custom fieldtype in Visual Studio with the desired functionality and then add it to an existing contenttype on the list, or create a custom contenttype with this new fieldtype and add that contenttype to the list.
    Ziga -- Junior SharePoint Developer
    Wednesday, September 28, 2011 11:38 AM
  • Hi Hulu,

    You can actually accomplish this with SPD. First, though, you need to customize the NewForm.

    To do this, open it in SPD and save it as something else, such as NewForm2.aspx. In short, you want to insert a new DataFormWebPart and hide (not delete) the default ListFormWebPart. In the new web part, you can then add your new field and apply conditional formatting based on it.

    You also have to change the default form for the list from NewForm to NewForm2.

    Please refer to the following for more details. It walks through the process in good detail.

    http://sharepoint07.wordpress.com/2008/02/05/customize-the-newformaspx/

    Best wishes,

    Eric

    Wednesday, September 28, 2011 1:45 PM
  • Hi BosEdison,

    I think the conditional formatting doen't work for this issue. In inforpath I can create different datasource view (sharepoint list datasource and form view). But in SPD conditional formatting I can only use list datasource, which can not apply to insert form.

    Perheps Ziga is right. I must use visual studio to pass the customizing. But I have no erxperience about it. I must learn it.

    Thursday, September 29, 2011 9:06 AM
  • Hi Hulu,

    Sorry for any confusion. One thing you can do is insert the new field as a column in the list in SharePoint via your browser, and hide it from any views if you want. If you have already customized your NewForm, you'll have to add it into the DataFormWebPart manually in SPD.

    You'll then be able to apply conditional formatting based on the field.

    Best,

    Eric

    Thursday, September 29, 2011 1:01 PM
  • Hi BosEdison,

    I have tested. At first for DataFormWebPart, conditional formatting can not be applied, the button is grey. It can only be applied to sharepoint Data View Controls. Second, I need to customized NewForm (if one field is selected in insert Form, other fields should be showed in insert Form), but conditional formatting works only for display Form.

    Thursday, September 29, 2011 1:37 PM
  • Hi Hulu,

    I've been trying to remember the specific process I used in a similar situation to make this work with the NewForm, including  going through old notes. In short, you will need a way to "pre-populate" the field in the NewForm that you want to use for the Conditional Formatting criteria.

    There are a number of ways to do this, most commonly using JavaScript, if you're proficient in it. I'm not, so I had to find another procedure.

    In my situation, the data was already in another list, and I passed it into the NewForm by appending the field to the URL that opened the NewForm. You could also set up an intro page that users see before opening the NewForm, and do the same thing. There they would make the selection for the data that will get pre-populated. To pass a Query String Variable to the NewForm, use an ampersand (formatted as &) at the end of the URL.

    In the NewForm itself, you will then need to populate the appropriate field with the info from the URL. The following link was the one that was most helpful to me, but not all of it applies and it took a bit of time tinkering before I was successful.

    http://geekswithblogs.net/SoYouKnow/archive/2009/10/29/setting-sharepoint-form-fields-using-query-string-variables-without-using.aspx

    Good luck,

    Eric

    • Marked as answer by Wayne Fan Thursday, October 6, 2011 6:52 AM
    Thursday, September 29, 2011 9:05 PM