1

I'm using this caml query in order to receive only the item with title "Full Day"

CamlQuery getFullDayHoursQuery = new CamlQuery();

                getFullDayHoursQuery.ViewXml =
                    @"<View>

                                <Where>
                                    <And>
                                    <Eq>
                                        <FieldRef Name='Title'/>
                                        <Value Type = 'Text'>Full Day</Value>
                                    </Eq>
                                    </And>
                                </Where>

                           </View>";

                ListItemCollection getFullDayHoursItem = durationSettings.GetItems(getFullDayHoursQuery);

I keep getting all the items of the list returned . I tried to change it by adding 'Full Days' or "Full Days" but the Caml Query helper always return me all the results.

Any ideas?

2 Answers 2

1

Try with this:

var employeeList = clientContext.get_web().get_lists().getByTitle("Employees");
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml
                         (
                          "<View>" +
                              "<Query>" +
                                  "<Where>" +
                                        "<Eq>" +
                                            "<FieldRef Name=\"EmpNickName\"/>" +
                                            "<Value Type=\"Text\">" + loginName + "</Value>" +
                                        "</Eq>" +
                                  "</Where>" +
                              "</Query>" +
                               "<RowLimit>1</RowLimit>" +
                         "</View>"
                       );

var items = employeeList.getItems(camlQuery);
clientContext.load(items, "Include(ID, Title)");
2
  • Actually it worked when i used the LinkTitle field instead of the Title field.
    – shak
    Commented Sep 25, 2017 at 7:42
  • Please, accept the answer!
    – Goshky
    Commented Sep 25, 2017 at 8:49
1

Solution was to use this code :

string fullDayOption = "Full Day";

                getFullDayHoursQuery.ViewXml =
                    @"<View>
                            <Query>
                                <Where>

                                    <Eq>
                                        <FieldRef Name='LinkTitle'/>
                                        <Value Type = 'Computed'>" + fullDayOption + @"</Value>
                                    </Eq>

                                </Where>
                           </Query>
                           </View>";

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.