Clarity

 View Only
  • 1.  GEL script read File from SharePoint Document Library

    Posted Aug 04, 2016 05:52 PM

    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];
       
    }
    }



  • 2.  Re: GEL script read File from SharePoint Document Library

     
    Posted Sep 19, 2016 05:59 PM

    Hi Lowell - I know you didn't get any responses for this one but was wondering if you were ever able to figure it out on your own? Thanks! Chris



  • 3.  Re: GEL script read File from SharePoint Document Library

    Posted Sep 20, 2016 05:23 PM

    Hi Chris,

    So far, no response to how to incorporate a JavaScript function in GEL.  Each time I try adding any JavaScript to a GEL script, the result will not compile. 

     

    The SharePoint Document library appears to be inaccessible to a Clarity GEL script.  But, my question still stands:  How do I incorporate a JavaScript Function into a GEL script?  Are there any examples of a successful incorporation of JavaScript into GEL?



  • 4.  Re: GEL script read File from SharePoint Document Library

    Posted Sep 20, 2016 06:22 PM

    So the readFile function looks to be an example from a html page that is hosted within a Sharepoint site.

     

    I suspect that there is a javascript include file that contains the SP class with appears to used to get the current context for the user. 

     

    clientContext = new SP.ClientContext.get_current();

     

    I play around with a JavaScript tag library for GEL a while ago but as we are OnDemand I kind of abandon it.

    Alternative Scripting Language 

     

    I suspect to accomplish this via GEL, one would need to instantiate a HttpClient  (org.apache.http).  Create a CredentialsProvider containing the NTCredentials to access the SharePoint site and attach them to the HttpClient.

     

    Execute an HttpGet  request which points to the SharePoint url for the file you want. Check the response status for OK and write the contents of the response buffer into a file on the CA PPM system.

     

    Close the HttpClient and check up any left over objects.

     

    V/r,

    Gene

     

     

     

     



  • 5.  Re: GEL script read File from SharePoint Document Library

    Posted Sep 28, 2016 01:00 PM

    Hi Gene,

    I'll try this.  I think I may need to see some examples of executing HttpGet requests.  I'll do some research and hope to have some good news for you.

    Thanks,

    Lowell



  • 6.  Re: GEL script read File from SharePoint Document Library

     
    Posted Sep 27, 2016 03:16 PM

    Hi Lowell - Did gcubed's response help? Thanks, Chris