
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)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);