0

I am creating termset in SharePoint Hosted App with below code. but it is giving error Access denied. You do not have permission to perform this action or access this resource. Whereas logged in user is owner for that group where i am creating this termset.

createTerm: function (termName) {
        var _this = this;
        //Current Context
        var context = SP.ClientContext.get_current();

        //Current Taxonomy Session
        var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);

        //Term Stores
        var termStores = taxSession.get_termStores();

        //Term Store under which to create the term.
        var termStore = termStores.getByName(_this.termStoreName);

        //Term Set under which to create the term.
        var termSet = termStore.getTermSet(_this.termSetId);

        //Create new guid
        var termGuid = new SP.Guid.newGuid()

        //Name of the term, LCID and a new GUID for the term.
        var newTerm = termSet.createTerm(termName, 1033, termGuid.toString());

        newTerm.set_isAvailableForTagging(true);

        context.load(newTerm);

        context.executeQueryAsync(function (sender, args) {
            _this.termMetadataString = termName + ";" + termGuid.toString();
            _this.upsertAuditFormItem("Term Metadata string");
        }, function (sender, args) {
            console.log(args.get_message())
            alert("Here it is throwing error. Which i mentioned earlier");
            AuditUtility.hideLoading();
        });
    },
  • Hi you are running managed metadata service application in sharepoint? – adilahmed Aug 9 '17 at 6:07
  • Managed Metadata service is up and running. – gachCoder Aug 9 '17 at 6:10
  • Have you applied taxonomy permission to app? – Samir Khimani Aug 9 '17 at 6:21
  • How to do that? – gachCoder Aug 9 '17 at 6:22
1

Looks like your app doesn't have permission to write data to the term store.

To provide permission , go to the Appmanifest.xml file and provide write permission the Taxonomy scope.

enter image description here

Deploy the app again and it should work now.

  • Still i am facing same error. Access denied. You do not have permission to perform this action or access this resource. – gachCoder Aug 9 '17 at 16:51
  • you can try 2 things - 1) use the sharepoint admin account 2) change the permission from write to full control. – Gautam Sheth Aug 9 '17 at 16:56
  • 1. Account with which i am logged in that is Admin only. 2. In Taxonomy, there are only two permissions defined, one is Read and another is Write. So How can we switch to Full Control? – gachCoder Aug 9 '17 at 17:04

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.