1

I have this custom action in sharepoint where the page will be redirected to another url but the components of the URL are dependent on a fielvalue in its parent folder, Request Failed. Specified Argument was out of Range, Parameter Name: Index undefined keeps popping up every time i press the button for the first time, but after that the code runs smoothly

here is the part of my code where the error occurs

                        function getParentFolder() {
                            console.log('getParentFolder')
                            var defer = $.Deferred();
                            var urlParams = new URLSearchParams(window.location.search);
                            var myParam = urlParams.get('RootFolder');
                            //var context = SP.ClientContext.get_current();
                            var web = context.get_web();
                            var folder = web.getFolderByServerRelativeUrl(myParam);
                            context.load(folder);
                            context.executeQueryAsync(function (data) {
                                defer.resolve(folder);
                                // onFolderSucceeded(folder)
                        }, function(sender, args){
                            defer.reject(sender, args);
                        })
                        return defer.promise();
                        };

its goes to defer.reject every time i press button for the first time

2
  • Update: I found out that the 'data' in my context.executeQueryAsync(function (data) is not defined during the first click, but in the following clicks the data is a SP.ClientRequest Commented Dec 7, 2018 at 4:56
  • Does this also appear if you wrap SP.SOD.executeFunc('SP.js', 'SP.ClientContext', function() { }); around your code?
    – Celophysis
    Commented Dec 7, 2018 at 9:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.