0

I have a problem with developing an app for sharepoint.

While the Default.aspx works fine, the ClientWebPart.aspx does not. I load the whole SharepointJSFiles with

    <SharePoint:ScriptLink language="javascript" name="core.js" OnDemand="true" runat="server" />

before i also tried with

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

I call my function with:

SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'SP.UserProfiles.js');

in the loadUserData function i create a clientContext with

var clientContext = new SP.ClientContext.get_current();

as mentioned - when I do this within my Default.aspx file everything works fine, but in the ClientWebPart.aspx it tells me:

Unable to get property 'get_current' of undefined or null reference

Although it is nearly the same code.

What am I doing wrong? Do I need to reference the Scripts different in the ClientWebPart.aspx than in the Default.aspx ?

1

Seems like I solved it on my own - i referenced the Scripts manually (Although I am not sure which of these I really need for my operation) and now it works.

If someone may has the same issue:

<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/_layouts/15/init.js"></script>
<script type="text/javascript" src="/_layouts/15/mQuery.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.ui.dialog.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="/_layouts/15/callout.js"></script>
<script type="text/javascript" src="/_layouts/15/SP.UserProfiles.js"></script> 
0

You need the sp.js and sp.runtime.js libraries for ClientContext:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.