web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

"hostUrl" is custom defined to be the Sharepoint URL in below code. But it shows undefined while debugging. basically i need to access sharepoint files through javascript in webresource.

(0) ShareShare
ReportReport
Posted on by 19

<script src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js" type="text/javascript"> </script> <script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"> </script> <script type="text/javascript">

document.onreadystatechange = function () {
if (document.readyState === 'complete') {
loaddata();
debugger;
var hostweburl;

hostweburl =
decodeURIComponent(
getQueryStringParameter("https://*********/*****/******/****") //my sharepoint URL.
);

// The js files are in a URL in the form:
// web_url/_layouts/15/resource_file
var scriptbase = hostweburl + "/_layouts/15/";

// Load the js files and continue to
// the execOperation function.
$.getScript(scriptbase + "SP.Runtime.js",
function () {
debugger;
$.getScript(scriptbase + "SP.js", execOperation);
}
);

// Function to execute basic operations.
function execOperation() {

// return the file paths.

}

}
}

</script>

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    PranavShroti Profile Picture
    4,510 on at
    RE: "hostUrl" is custom defined to be the Sharepoint URL in below code. But it shows undefined while debugging. basically i need to access sharepoint files through javascript in webresource.

    Hi,

    If its only one SP.Runtime.js file then can you not upload it as a web resource in Dynamics to refer from there. It would be much easier and faster rather than loading it from SharePoint.

    I am not sure if SharePoint will allow (security) you to access files inside a layout folder.

    hope this helps,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans