Here I was trying to figure out how to set some fields in my new item form in SharePoint from query string. My only problem was not do any coding. I was allowed to use SharePoint designer and all its functionality. Below is my scenario:
Our organization is using BPOS and its features. We have our SharePoint company portal on BPOS. I was asked to make a "Incident Management" feature on SharePoint. I created two lists namely Incident Details and Call Details. Incident Details list is created using issue tracking list template, Call Details list was created using the using Custom List Template. My look up in call details list should be ID of incident reported. As I did not wanted my users to do any mistakes and select any other Incident ID, I was looking for a solution which would populate my Incident ID field automatically.
After searching for long time i was able to find some answers which helped me solve my problem. Below is step by step guide for action I took:
1. In SharePoint designer I opened my DispForm.aspx page for Incident List.
2. Added a new Link For adding call details for selected incident. Add this link after </WebPartPages:WebPartZone>
Below is what is added as code:
<script type="text/javascript" language="javascript" >
function RedirectToAddCallDetails()
{
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split('=');
if (ft[0] == 'ID') {
window.location = "http://mds-devp:8025/Lists/CallDetails/NewAutoFillUpForm.aspx?IncidentId=" + ft[1];
}
}
}
</script>
<a href="#" onclick="javascript: RedirectToAddCallDetails();" >Click Here to Add Call Details</a>
This Redirected me to my call details page directly with IncidentId in query string.
3. Go to CallDetails list in SPD, right click on new form and select “New From Existing Page”. This should create a new page for you from the existing form page. If this does not works copy paste the NewForm.aspx in same location this create a duplicate copy of page and rename it to NewAutoFillUpForm.aspx
4. Open the NewAutoFillUpForm.aspx of call list and delete the default ListFormWebPart from page. For doing this select the web part in design mode switch to code and delete the selected web part code lines. After deleting make sure you save the page.
![]() |
Default New Form Page Design View |
![]() |
Default New Form Page Code View |
5. In ZoneTemplate add new form
Insert Menu --> SharePoint Controls--> Custom List Form.
![]() |
Menu choice |
Select Call Details in list drop down and New Item Form from the options below it.
![]() |
Add new DataFormWebpart |
6. Go to design view of Page, select DataFormWebPart and click Parameters.
7. Data View Parameters popup will appear.
a. In this add new parameter by any name say IncidentId.
b. In parameter source on right side select Query String
c. In Query String Variable give your query string variable name in my case IncidentID. Click OK.
![]() |
Design view of new data form webpart |
![]() |
parameters popup |
![]() |
New parameter added by name IncidentId |
8. Select the IncidentID SharePoint Form Field and bring up its Common FormFields Task pane. Select “Data Field” as IncidentID and in “Format as” select TextBox. This will change the field to an ASP text box type field.
![]() |
Default Incidentid data field |
![]() |
IncidentData field after changing to textbox |
9. Now go to code view and change the text property of textbox from
text="{@IncidentId}" to text="{$IncidentId}". $IncidentId is the parameter that we added earlier in step 7. If you wish you can make this text box read only by making readonly attribute of text box true.
Viola this did my code. Run once and test it.