1

I have an application in JSOM which updates property of document set in SharePoint online. I am updating 6 taxonomy fields, 3 text fields, 1 user field. I am also assigning permissions to a user. I am getting following error:

The operation has timed out.

I have recorded execution time required to update all data in single ExecuteQueryAsync().

Time required for updating values : 94 sec.

Time required for updating values without taxonomy fields : 26 sec

Time required for updating only taxonomy fields : 94 sec.

From above mentioned observations, I am sure that it is taking time to update only Taxonomy fields.

Additionally, this is happening only in case where Microsoft office documents are present in document set.

I have also tried to set time out value as - 0 i.e. no timeout, but it didnt work.

Thanks in advance.

Please find below my code:

function Test_TimeOutSet_DocumentSet() {
//get document set list item
//set value of document set list item fields
$.getScript(scriptbase + 'SP.Runtime.js', function () {
    $.getScript(scriptbase + 'SP.js', function () {
        $.getScript(scriptbase + 'SP.DocumentManagement.js', function () {
            $.getScript(scriptbase + 'SP.RequestExecutor.js', function () {
                $.getScript(scriptbase + 'init.js', function () {
                    $.getScript(scriptbase + 'sp.taxonomy.js', function () {
                        try {
                            taxField1.setFieldValueByValueCollection(docSetItem, terms1);
                            taxField2.setFieldValueByValueCollection(docSetItem, terms2);
                            taxField3.setFieldValueByValueCollection(docSetItem, terms3);
                            taxField4.setFieldValueByValueCollection(docSetItem, terms4);
                            taxField5.setFieldValueByValueCollection(docSetItem, terms5);
                            taxField6.setFieldValueByValueCollection(docSetItem, terms6);

                            //Set Author
                            var authorUserArray = userval
                            var users = new Array();
                            for (var i = 0; i < authorUserArray.length; i++) {
                                users.push(SP.FieldUserValue.fromUser(authorUserArray[i].Login));
                            }
                            docSetFolderItem.set_item(knowledgeLibField_Author, users);
                            docSetFolderItem.update();

                            //Set Authors permissions
                            var roleDefBindingColl = SP.RoleDefinitionBindingCollection.newObject(context);
                            roleDefBindingColl.add(context.get_web().get_roleDefinitions().getByName(_global_KnowledgeCustomPermission));
                            for (var i = 0; i < authorsObjArray.length; i++) {
                                docSetFolderItem.get_roleAssignments().add(authorsObjArray[i], roleDefBindingColl);
                            }
                            //Set Everyone except external users permissions
                            roleDefBindingColl = SP.RoleDefinitionBindingCollection.newObject(context);
                            roleDefBindingColl.add(context.get_web().get_roleDefinitions().getByType(SP.RoleType.reader));
                            docSetFolderItem.get_roleAssignments().add(everyUserExceptExternal, roleDefBindingColl);

                            //Set contribution type
                            //Set description field in Doc set item
                            docSetFolderItem.set_item(knowledgeLibField_ContributionType, documentSetData.ContributionType);
                            //Set third party authors
                            docSetFolderItem.set_item(knowledgeLibField_ThirdPartyAuthor, documentSetData.ThirdPartyAuthors);
                            //set Engagement WBS
                            docSetFolderItem.set_item(knowledgeLibField_EngagementWBS, documentSetData.EngagementWBS);
                            //set terms and condition value to true
                            docSetFolderItem.set_item(knowledgeLibField_TermsAndConditions, true);
                            _test_global_startTimer = Date.now();
                            docSetFolderItem.update();
                        }
                        catch (err) {
                            console.log("Message:" + err.message + "||Name:" + err.name + " ", "Set all fields with valid values");
                            throw err;
                        }
                        context.executeQueryAsync(function () {
                            _test_global_endTimer = Date.now();
                            alert("SUCCESS: Time required-" + (_test_global_endTimer - _test_global_startTimer) / 1000);
                        }, function (sender, args) {
                            _test_global_endTimer = Date.now();
                            alert("ERROR: Time required-" + (_test_global_endTimer - _test_global_startTimer) / 1000);
                            console.log("Message:" + args.get_message() + " ", "After ExecuteQueryAsync:Set all fields with valid values");
                        });
                    });
                });
            });
        });
    });
});
}
  • 1
    Any reason you can't break the single query into smaller batches? Do 1/3 of the list at a time or 1/4 or 100 items or whatever then executeQueryAsync then do the next batch, wait for all of the executes to finish and signal that you're done using a promise or something similar. – John-M Apr 7 '16 at 12:32
  • I also tried to break taxonomy field block into two ExecuteQueryAsync(), but got time required as 90 and 81 seconds respectively. I thought adding each taxonomy update separately is not a good solution. This is happening only in case of Microsoft documents. – AkshayP Apr 7 '16 at 12:35

Your Answer

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

Browse other questions tagged or ask your own question.