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

Fields being ignored #20

Open
donebydavid opened this issue Nov 3, 2019 · 2 comments
Open

Fields being ignored #20

donebydavid opened this issue Nov 3, 2019 · 2 comments

Comments

@donebydavid
Copy link

When specifying fields, they just seem to be ignored. For example below

var data = {
    listName: "Primary Bookings",
    fields: ["EventDate", "EndDate"," Title"]
}

spcalpro.getCalendarEvents(data).ready(function(data, obj) { 
    if (obj.error) console.error(obj.error);                        
    console.table(data);
});
@samperrow
Copy link
Owner

@donebydavid I do not do sharepoint development anymore, and I haven't used this little lib in several months, and I simply do not have the time to research issues. You are welcome to submit a PR and I can take a look.

But just giving this a quick glance, those 3 fields are among the default fields which are always returned for a recurring item. the fields prop is generally only meant to retrieve custom fields that are not returned by default.

@pikebike
Copy link

pikebike commented Nov 5, 2019

@donebydavid
The fields are being ignored because the CAML query isn't set up to include the fields for calendar lists, so anything you list in the fields array gets ignored.

I updated the code at line 82 to this:
var endRecurringCaml1 = '<OrderBy><FieldRef Name="EventDate"/></OrderBy>';

After that I then added a new variable with the remainder like this:
var endRecurringCaml2 = '<queryOptions><QueryOptions><RecurrencePatternXMLVersion>v3</RecurrencePatternXMLVersion><ExpandRecurrence>TRUE</ExpandRecurrence><RecurrenceOrderBy>TRUE</RecurrenceOrderBy><ViewAttributes Scope="RecursiveAll"/></QueryOptions></queryOptions>';

Line 97 is what returns the query string, but the endQuery variable is what contains the fields, so I updated line 97 to this:
query += beginRecurringCaml + endRecurringCaml1 + endQuery + endRecurringCaml2;

Also, in line 107 he has the <fieldRef> tag as self-closing, but all of the references I see have them as open and closing tags, so I updated line 107 to:
viewFields += '<FieldRef Name="' + userObj.fields[i] + '"></FieldRef>';

After making those changes, all fields I input are added to the viewfields in addition to the default fields. But like @samperrow said, the fields you listed are the default fields and should be included regardless.

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

No branches or pull requests

3 participants