Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw error when call folder.FindFolders(folderView) #178

Closed
thlee927 opened this issue Apr 24, 2017 · 5 comments
Closed

Throw error when call folder.FindFolders(folderView) #178

thlee927 opened this issue Apr 24, 2017 · 5 comments
Assignees
Labels
Milestone

Comments

@thlee927
Copy link
Contributor

if I pass single argument to folder.FindFolders function, it throw an error.
I have check the source code, it seem have a bug at this line:
return this.Service.FindFolders(this.Id, view);

In my case, it will pass the null to Service.FindFolders function. Please help to check, thanks.

ews-javascript-api/src/js/Core/ServiceObjects/Folders/Folder.ts:

    FindFolders(viewOrSearchFilter: FolderView | SearchFilter, view?: FolderView): Promise<FindFoldersResults> {
        this.ThrowIfThisIsNew();
        //todo: better argument check with ewsutilities
        var argsLength = arguments.length;
        if (argsLength < 1 && argsLength > 2) {
            throw new Error("invalid arguments, check documentation and try again.");
        }

        if (viewOrSearchFilter instanceof FolderView) {
            return this.Service.FindFolders(this.Id, view);
        }
        else if (viewOrSearchFilter instanceof SearchFilter) {
            if (typeof view === 'undefined' || !(view instanceof FolderView)) {
                throw new Error("Folder.ts - FindFolders - incorrect uses of parameters at 2nd position, must be FolderView");
            }
            return this.Service.FindFolders(this.Id, viewOrSearchFilter, view);
        }
        else {
            throw new Error("Folder.ts - FindFolders - incorrect uses of parameters at 1st position, must be FolderView or SearchFilter");
        }
    }
@gautamsi
Copy link
Owner

this is how it is expecting the argument based on c# version.

How are you making it pass null? are you passing null for view? or Folder.Id is null?

@thlee927
Copy link
Contributor Author

thlee927 commented May 2, 2017

I use this function to list all sub folder.
I try to call this function like this:
folder.FindFolders(folderView);
But it will throw an error.

If I call the function like this:
folder.FindFolders(folderView, folderView);
it will return the correct result.

@gautamsi
Copy link
Owner

gautamsi commented May 2, 2017

you may want to share full code for repro. use gitter to send private message

@gautamsi gautamsi self-assigned this May 2, 2017
@gautamsi gautamsi added the bug label May 2, 2017
@gautamsi gautamsi added this to the 0.9.0 milestone May 2, 2017
@gautamsi
Copy link
Owner

gautamsi commented May 2, 2017

problem is with the line:

       if (viewOrSearchFilter instanceof FolderView) {
            return this.Service.FindFolders(this.Id, view);
        }

it should be

       if (viewOrSearchFilter instanceof FolderView) {
            return this.Service.FindFolders(this.Id, viewOrSearchFilter);
        }

gautamsi added a commit that referenced this issue May 19, 2017
@gautamsi
Copy link
Owner

ews-javascript-api@0.9.0-dev.6 containing this change is published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants