I have the above code when I try to execute the following piece of code. The query works for me in CAML Designer, what am I missing here?
public static SPRemoteEventServiceStatus CreateProjectSiteAndUpdateSiteOnList(SPRemoteEventProperties properties)
{
SPRemoteEventResult result = new SPRemoteEventResult();
try
{
using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
{
if (clientContext != null)
{
//Get the item that we are trying to add to the project list
List projectList = clientContext.Web.Lists.GetById(properties.ItemEventProperties.ListId);
ListItem item = projectList.GetItemById(properties.ItemEventProperties.ListItemId);
clientContext.Load(item);
clientContext.ExecuteQuery();
//Get client name from that list item
TaxonomyFieldValue taxFieldValueClient = item["Nombre_x0020_Cliente"] as TaxonomyFieldValue;
string nombreCliente= taxFieldValueClient.Label;
//Get the client we need from the clientList, matching the name on the project list
Microsoft.SharePoint.Client.List clientList = clientContext.Web.Lists.GetByTitle("Clientes");
clientContext.Load(clientList);
clientContext.ExecuteQuery();
string strUrlCliente=default(string);
if (clientList != null && clientList.ItemCount > 0)
{
CamlQuery camlQuery = new CamlQuery();
//we know client name is unique so query should return one or zero rows on the client list
camlQuery.ViewXml = "<View><Query><Where><Eq>" +
"<FieldRef Name='Nombre_x0020_Cliente' />" +
"<Value Type='TaxonomyFieldType'>" + nombreCliente + "</Value>" +
"</Eq><ViewFields><FieldRef Name='Sitio_x0020_Cliente' /></ViewFields></View>";
ListItemCollection listItems = clientList.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();

0 commentaires:
Enregistrer un commentaire