Tuesday, October 25, 2016

Add Multiple Party list Users MSCRM Email in PreCreate by splitting String

Hi all,

Pleaes find the Below code for Creating Lead and Adding that user into activity party List

createLead("test;test",service,from);


        public static void createLead(string splitString, IOrganizationService service, string fieldName, Entity target)
        {
            string[] arrayfromtextEmail = splitString.Split(';');
            EntityCollection collectionEmailAddress = new EntityCollection();
            foreach (string loopWord in arrayfromtextEmail)
            {
                Guid getLeadID = checkEmailIDExisits(service, loopWord);
                if (getLeadID == Guid.Empty)
                {
                    Lead createLead = new Lead();
                    createLead.FirstName = loopWord.Substring(0, loopWord.IndexOf("@"));
                    createLead.EMailAddress1 = loopWord;
                    getLeadID = service.Create(createLead);
                }
                Entity Emailparty = new Entity(ActivityParty.EntityLogicalName);
                Emailparty["addressused"] = loopWord;
                Emailparty["partyid"] = new EntityReference(Lead.EntityLogicalName, getLeadID);
                collectionEmailAddress.Entities.Add(Emailparty);
            }
            target[fieldName] = collectionEmailAddress;
        }

No comments:

Post a Comment

How to Run Microsoft Flow for Every one Month

Introduction: In this Blog we will see how to Run Microsoft Flow for Every one Month. Implementation Steps:   1. Navigate to  https://make.p...