Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to copy items from a list in one site and update/paste them into a list in another site, but I can't get it to work. Please help. I have my references to jQuery and SPServices in the master page, so that's why you don't see them here.

<script type='text/javascript'>

function getItems()
{
    $().SPServices({
        operation: 'GetListItems',
        listName: '{79F42AED-47C1-4CDD-840D-748DF70694B7}',
        CAMLViewFields: '<ViewFields Properties="True"/>',
        completefunc: function(xData, Status)
        {
            $(xData.responseXML).find('[nodeName["z:row"]').each(function()
            {
               var fmsCategory = $(this).attr('ows_Category');
               var fmsCase = $(this).attr('ows_Case');
               var fmsPm = $(this).attr('ows_PM');
               var fmsTotalValue = $(this).attr('ows_Total_x0020_Case_x0020_Value');
               var fmsUndeliveredValue = $(this).attr('ows_Undelivered_x0020_Value');
               var fmsSystem = $(this).attr('ows_System'); 

               updateItems(fmsCategory, fmsCase, fmsPm, fmsTotalValue, fmsUndeliveredValue, fmsSystem);
             });
          }
      });
}

function updateItems(fmsCategory, fmsCase, fmsPm, fmsTotalValue, fmsUndeliveredValue, fmsSystem)
{
    $().SPServices(
    {
        operation: 'UpdateListItems',
        webURL: 'http://intranet/sites/dashboard/peo/fms',
        listName: '{4EE12A8F-9C93-4B9A-8F71-2F809779329E}',
        updates: '<Batch OnError="Continue" PreCalc="True">' + 
            '<Method ID="1" Cmd="New">' +
            '<Field Name="Category">'+ fmsCategory +'</Field>' +
            '<Field Name="Case">'+ fmsCase +'</Field>' +
            '<Field Name="PM">'+ fmsPm +'</Field>' +
            '<Field Name="Total Case Value">'+ fmsTotalValue +'</Field>' +
            '<Field Name="Undelivered Value">'+ fmsUndeliveredValue +'</Field>' +
            '<Field Name="System">'+ fmsSystem +'</Field>' +
            '</Method>' +
         '</Batch>',
         completefunc: function(xData, Status)
         {
              alert('FMS Products List has successfully copied.');      
         }
    });
}
</script>
<input type='button' id='clone' value='Clone List' onclick='getItems()'></input>
share|improve this question
add comment

1 Answer

I was using the Display Name in some of the <Field Name> updateItems function. Changed to Static Names and it works.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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