I've came across a requirement where I need to fill some of the fields in newform.

So basically we start from view item, where we can see an existing item in a list, then we click something like move to new form, and the fields from this item, should be filled in the new form page, and after clicking ok, the new item should be added to the list.

I was thinking doing this with the jquery, where on click I could call a "new item form" with a query string "?sameitem={itemId}" and with javascript, i could query this list for that item and then dynamically fill all the fields in the form.

Could anyone assist me with a javascript code for sharepoint 2007? Or foward me to a existing kind of solution?

Also important is that i have to do it dynamically i don't know on what content type this feature will be used, so i need to retrieve from CT the path to the new form page, as it can be different from the default, and also using dom to find the correct field and fill them in.

Any idea?

1 Answer 1


I would use jQuery and SPServices in the custom new item form and get the existing item with SPServices function GetListItems (example).

So something like this

var existingID = 5; // GET THIS FROM QUERYSTRING

$(document).ready(function() {
    operation: "GetListItems",
    async: false,
    listName: "Announcements",
    CAMLViewFields: "<ViewFields><FieldRef Name='FieldA' /><FieldRef Name='FieldB' /></ViewFields>",
    Query: "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Integer'>" + existingID + "</Value></Eq></Where></Query>"
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
      $("#fieldARef").val($(this).attr("ows_FieldA")); // get reference to field's HTML element in the form using jQuery and put in the value you get from SPServices     

Haven't tested this code, just took SPServices example and modified it to suit your scenario.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.