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