I’m trying to apply a site policy from a SharePoint hosted add-in using JSOM. SharePoint Online.

I have referenced the SP.Policy.js library and tried to use the static methods in the SP.InformationPolicy.ProjectPolicy namespace.

If I manually apply a site policy using the web interface I can use doesProjectHavePolicy and getProjectCloseDate to get some information about the applied policy.

I can even close the site using closeProject.

However, if I try to get a list of available site policies using getProjectPolicies I get an empty list even though I know that I have three available policies. No error or similar, just an empty list. I need this list to be able to apply a site policy, that is my goal.

I have also tried to use getCurrentlyAppliedProjectPolicyOnWeb to get the current policy but receive an error when I try to load the object saying: a.get_$19_0 is not a function from sp.runtime and SP.DataRetrievalWithExpressionString.load.

Code example:

context = SP.ClientContext.get_current();
appContext = new SP.AppContextSite(context, hostweburl);
hostWeb = appContext.get_web();


context.executeQueryAsync(function () {

    policies = SP.InformationPolicy.ProjectPolicy.getProjectPolicies(context, hostWeb);
    policy = SP.InformationPolicy.ProjectPolicy.getCurrentlyAppliedProjectPolicyOnWeb(context, hostWeb);
    hasPolicy = SP.InformationPolicy.ProjectPolicy.doesProjectHavePolicy(context, hostWeb);
    date = SP.InformationPolicy.ProjectPolicy.getProjectCloseDate(context, hostWeb);
    context.load(policies); // Variant 1. Return an object but no policies.
    context.load(policy); // Variant 2, generate an error.

    context.executeQueryAsync(function () {
            policyEnumerator = policies.getEnumerator();

Anyone out there with a working example of a script that apply a site policy in a SharePoint hosted app?

I can also add that I have done the same thing using PowerShell and it works perfectly.

  • Quick update. I opened a ticket with Microsoft about this and after some digging with their engineers they found a possible problem, a bug, in the JSOM library for the site policies. We have made a request to the product team to resolve this. Oct 14, 2016 at 8:54

1 Answer 1


I eventually found the problem and also the solution. I accidently failed to load the library sp.runtime.js in a proper way. Everything else in my app still worked so I didn’t notice this apparent problem until I got some support from Microsoft.

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.