web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get Text between comma seperated text field and set it on Address field.

(0) ShareShare
ReportReport
Posted on by 277

Hi Experts

I ran into this scenario today. On create of a child record, it should create a new account and assign it to child again. Here I need to get text from a multiple lines of text field(this is on child record) and update it in individual address fields of composite fields. 

The existing format is < 1234 Maple Street, Edison , NJ 12345 >

Need to get the first part of string and set it in address_street1 of composite field

city in address_city and state in address_state and same with Zip code. 

This should happen on create of a record. i tried an OOB workflow to create an account, everything works fine except for the address field as it is a Composite field. Is there a code that I could use to make it happen?

Its fine if I have to create a new account record using a plugin instead of workflow. 

Thank you

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Michel Gueli Profile Picture
    982 on at

    Maybe this could help you:

    var addressList = "1234 Maple Street, Edison , NJ 12345".Split(',').ToList<string>();        

               var account = new Entity("account");

               if(addressList.Count > 0)

                   account.Attributes.Add("address1_line1", addressList[0]);

               if (addressList.Count > 1)

                   account.Attributes.Add("address1_city ", addressList[1]);

               if (addressList.Count > 2)

               {

                   var temp = addressList[2];

                   var result = temp.Split(' ').ToList<string>();

                   if(result.Count > 0)

                       account.Attributes.Add("address1_stateorprovince", result[0]);

                   if (result.Count > 1)

                       account.Attributes.Add("address1_postalcode", addressList[1]);

                   service.Create(account);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans