0

I currently use:

  • For each project, a sharepoint site in O365 and a sharepoint list for all the project activities

  • A static responsive html5+css site to report each project progress to the Board. Of course, all project activities are currently manually updated into the HTML5+CSS.

    The problem is that i'm doing twice the work. I'm Creating and updating each project activity in each SP project site and manually updating each project site in an SP external solution (HTML5+CSS)!

I know that SP has a REST API that I can use to automatically generate the "external" HTML file and populate the sharepoint list items that I want... But I was only able to find the code below that doesn't work:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices.min.js"></script>

<script language="javascript" type"text/javascript">
    SITE = "my current project site"

   $(document).ready(function() {
      $().SPServices ({
         operation: "GetListItems",
         async: false,
         listName: "Project Issues",
         CAMLViewFields:"<ViewFields><FieldRef Name="Title" /><FieldRef Name="Owner" />
         completefunc: function (xData, Status) {
           $(xData.responseXML).find("z\\:row, row").each(function() {
             var dTitle = $(this).attr("ows_Title");
             //...repeat with the other columns.
           });
       });
   });

    document.getElementById("dTitle").innerHTML = dTitle
     // ... so on repeat with the other list columns.
</script>
</body>
</html>

Can You help me?

1 Answer 1

0

add the following Ref in Head

<script type="text/javascript" src="_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="_layouts/15/sp.js"></script>

Try to run SP.SOD.executeFunc before any SPService()

jQuery(document).ready(function ()
{
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', GetListItems);
}); 

function GetListItems() {

$().SPServices ({
         operation: "GetListItems",
         async: false,
         listName: "Project Issues",
         CAMLViewFields:"<ViewFields><FieldRef Name="Title" /><FieldRef Name="Owner" />
         completefunc: function (xData, Status) {
           $(xData.responseXML).find("z\\:row, row").each(function() {
             var dTitle = $(this).attr("ows_Title");
             //...repeat with the other columns.
           });
       });
   });

    document.getElementById("dTitle").innerHTML = dTitle

}
4
  • Thanks @m-qassas. It didn't work beacuse the links of the 'sp.runtime.js' and 'sp.js' libraries are wrong. Can you send me the correct link, please!
    – Joni
    Aug 19, 2016 at 10:44
  • is this page that has this code hosted inside SharePoint portal ? Aug 19, 2016 at 12:35
  • Nop! It's hosted outside sharepoint! I've corrected the link but it doesn't work also!
    – Joni
    Aug 20, 2016 at 22:59
  • Dear based on the SPService author he said While the pages where you use SPServices don't have to be within SharePoint, it's common to run into authentication issues if they are not. Either SharePoint doesn't know the user's identity or there can be cross-domain scripting issues. There are far too many variations in all of this for me to usually give a yes or no answer. check his discussion here spservices.codeplex.com/discussions/267417 , So you should try to add your html code to content editor inside SharePoint Aug 21, 2016 at 9:12

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.