AnsweredAssumed Answered

GEL script read File from SharePoint Document Library

Question asked by Lowell on Aug 4, 2016
Latest reply on Sep 28, 2016 by Lowell

Question:  Has anyone successfully used GEL to load a document from a SharePoint Document Library?

 

If so, what command worked?

 

I have a file in a SharePoint Document Library.  When I attempt to load this file using GEL script, it says "file cannot be found".

<file:readFile commentIndicator="#" delimiter="," embedded="false" fileName="${PLocalDirectory}/${vFile}" var="input"/>

 

 

One of the recommendations was to use JavaScript functions to read the file.  How do I include JavaScript functions into a GEL script?

 

For example, the recommended JavaScript function to read from a SharePoint Document Library is (below).  How do I incorporate this into a GEL script?:

 

function readFile(resultpanel) {
   
var clientContext;
   
var oWebsite;
   
var fileUrl;

    clientContext
= new SP.ClientContext.get_current();
    oWebsite
= clientContext.get_web();

    clientContext
.load(oWebsite);
    clientContext
.executeQueryAsync(function () {
        fileUrl
= oWebsite.get_serverRelativeUrl() +
           
"/Lists/Shared Documents/TextFile1.txt";
        $
.ajax({
            url
: fileUrl,
            type
: "GET"
       
})
           
.done(Function.createDelegate(this, successHandler))
           
.error(Function.createDelegate(this, errorHandler));
   
}, errorHandler);

   
function successHandler(data) {
        resultpanel
.innerHTML =
           
"The content of file \"TextFile1.txt\": " + data
   
}

   
function errorHandler() {
        resultpanel
.innerHTML =
           
"Request failed: " + arguments[2];
   
}
}

Outcomes