Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 71679

Forum Post: RE: How validate entity before sending email ?

$
0
0
I would not recommend to perform the following code for every single entity, as the RetrieveEntityRequest is not the fastest. Perhaps it would be sensible to pre-set your system and set expected entities to be "Sending email (If an email field does not exist, one will be created)" setting on Entity via customisations. Alternately, retrieve entities metadata before you enter the loop, so your code does not repeat the same checks over and over. The following code should suit your exact code: else { //here we add generic code for any entity RetrieveEntityRequest retrievesEntityRequest = new RetrieveEntityRequest { EntityFilters = EntityFilters.Entity, LogicalName = entityName }; RetrieveEntityResponse retrieveEntityResponse =(RetrieveEntityResponse)_serviceproxy.Execute(retrievesEntityRequest); EntityMetadata isActivityParty = retrieveEntityResponse.EntityMetadata["IsActivityParty"]; if (isActivityParty == true) { String emailAddress = currentEntity.GetAttributeValue ("emailaddress"); if (!String.IsNullOrEmpty(emailAddress) { result.Add(emailAddress); } } } Thanks, Piotr

Viewing all articles
Browse latest Browse all 71679

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>