0

I have the following code which returns me a value like this:

"1;#empresa1|6507d102-8c2c-4072-b8bc-c4c67636e091"

The value I am interested in its: empresa1

Is there anyway I can get it in an item adding event on a remote event receiver without string manipulation??

public static SPRemoteEventResult CreateClientSiteAndUpdateSiteOnList(SPRemoteEventProperties properties)
{
     SPRemoteEventResult result = new SPRemoteEventResult();
     try
     {
         using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
         {
              if (clientContext != null)
              {
                  var afterProperties = properties.ItemEventProperties.AfterProperties;
                  afterProperties["Nombre_x0020_Cliente"].ToString()
1
  • 1
    That format is fixed. So there is no problem with using String Manipulation. Jan 27 '15 at 23:18
1

You can try this

TaxonomyFieldValueCollection txColl = afterProperties["Nombre_x0020_Cliente"] as TaxonomyFieldValueCollection;
if (txColl != null) {
    foreach (TaxonomyFieldValue t in txColl) {
        if (t.Label != null)
            //t.Label
    }
}
3
  • its a remote event receiver, that doesnt work, TaxonomyFieldValueCollection is null Jan 27 '15 at 23:32
  • 1
    Ok if you try TaxonomyFieldValue t = afterProperties["Nombre_x0020_Cliente"] as TaxonomyFieldValue are you getting the object? Jan 27 '15 at 23:35
  • also null, check comment Jan 27 '15 at 23:45

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.