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?

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)");
  • Actually it worked when i used the LinkTitle field instead of the Title field. – shak Sep 25 '17 at 7:42
  • Please, accept the answer! – Goshky Sep 25 '17 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, privacy policy and cookie policy

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