get list item (XML) and update coulm

Jan 8, 2014 at 7:53 AM
Hi,
1- read all data in library
2- separate XML and PDF file
3- Read XML data
4- Update PDF column from XML file

This is my cod :

<script language="javascript" type="text/javascript">
  $(document).ready(function() {

    $().SPServices({
      operation:  "GetListItems",
      listName: "Demo",
      CAMLViewFields: "<ViewFields><FieldRef Name='ID' /><FieldRef Name='Title' /><FieldRef Name='Name' /><FieldRef Name='EncodedAbsUrl'/></ViewFields>",
      CAMLQueryOptions: "<QueryOptions><Folder>/sites/DocumentCenter/(My site folder )</Folder></QueryOptions>",
      completefunc: function (xData, Status) {
        
        $("#divId").append("<table>");
        $(xData.responseXML).find("[nodeName='z:row']").each(function() {
          var ext = $(this).attr("ows_FileLeafRef").split(".");
          if ( ext[1]== "xml"){
            var url = $(this).attr("ows_EncodedAbsUrl");
            var id = $(this).attr("ows_ID");
            $().SPServices({
                operation: "GetItem",
                async: false,
                Url: url,
                completefunc: function(xDatax, xStatusx){
                    var out = xDatax.responseXML.documentElement.childNodes[0].childNodes[0].childNodes[2].textContent;
                    var decoded = window.atob(out);
                    var profile = $(decoded).find("profile").text();
                    var company = $(decoded).find("company").text();
                    var filename = $(decoded).find("filename").text();
                    var folder = $(decoded).find("folder").text();
                    var date = $(decoded).find("Document").text();
                    var department = $(decoded).find("Department").text();
                    var sender = $(decoded).find("Sender").text();
                    $("#divId").append("<tr><td><br>Profile : "+profile+"<br>Company : "+company+"<tr><td>Filename : "+filename+"<tr><td>Folder : "+folder+"<tr><td>Date : "+date+"<tr><td>Department : "+department+"<tr><td>Sender/Recipient : "+sender+"</td></tr>");
                    
                    $().SPServices({
                        operation: "GetItem",
                        CAMLQuery: "<Query><Where><Eq><FieldRef Name='Name' /><Value Type='Text'>" + filename +"</Value></Eq></Where></Query>",
                        async: false,
                        listName: "Demo",
                        completefunc: function(xDatay, Statusy) {
                            $(xDatay.responseXML).find("[nodeName='z:row']").each(function() {
                            var id = $(this).attr("ows_ID");
                            $().SPServices({
                                operation: "UpdateListItems",
                                async: false,
                                batchCmd: "Update",
                                listName: "Demo",
                                ID: id,
                                valuepairs: [["Sequel_x0020_No_x002e_", date]],
                                completefunc: function(xDatay, Statusy) {
                                
                                }
                            });
                            });
                        }
                    });                 
                }
                
            }); 
            }
        });
        $("#divId").append("</table>");
      }
    });
  });
</script>
Coordinator
Jan 8, 2014 at 1:28 PM
Are you having a problem? Showing your code for others?

M.
Jan 9, 2014 at 12:59 AM
sympmarc wrote:
Are you having a problem? Showing your code for others?

M.
Actually i had problem , but one of my friend help me to solve it ... tnx to her ...

but i got other question :

How to update the managed metadata field using spservice?
Coordinator
Jan 9, 2014 at 3:01 PM
Please try to spell out what you're looking for rather than just posting a pile of code, OK?

What do you want to do with managed metadata?

M.