# BPM C# Split string

**URL:** <https://www.epiusers.help/t/bpm-c-split-string/65765>\
**Category:** Epicor ERP 10\
**Tags:** bpm\
**Created:** [March 25, 2020, 7:37am UTC](https://www.epiusers.help/t/bpm-c-split-string/65765 "2020-03-25T07:37:44Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![LBARKER](https://www.epiusers.help/user_avatar/www.epiusers.help/lbarker/32/31072_2.png) [@LBARKER](https://www.epiusers.help/u/LBARKER)\
**Post date:** [March 25, 2020, 7:37am UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/1 "2020-03-25T07:37:44Z")

</div>

I’m trying to set the _specified_ field of BPM Data to the _specified_ expression

The field is _Char3_ the expression I’m trying is _ttQuoteHedRow.ShipToAddrList_

I can get it to display as a string but I can’t get it to split on “~”

Any clues please, I’m new to C#

---

<div class="post-metadata">

**Author:** ![A.Baeisa](https://www.epiusers.help/user_avatar/www.epiusers.help/a.baeisa/32/8988_2.png) [@A.Baeisa](https://www.epiusers.help/u/A.Baeisa)\
**Post date:** [March 25, 2020, 8:34am UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/2 "2020-03-25T08:34:45Z")

</div>

@LBARKER  
i think what you need is in this old post!

> [@C# Code help anyone?](https://www.epiusers.help/t/c-code-help-anyone/52749):
>
> Hi guys, I need a bit of help / advice on a small BPM which I am trying to write. I have a custom field (character03) on the QuoteDtl which holds a comma delimited character string. This string contains location references to be printed on labels. There is a check at the beginning to replace unwanted carriage returns double commas etc to hopefully end up with a string like this; ref1,ref2,ref3,ref4,ref5…etc etc So far so good. However, because we are in the construction industry and these ref…

---

<div class="post-metadata">

**Author:** ![timshuwy](https://www.epiusers.help/user_avatar/www.epiusers.help/timshuwy/32/90122_2.png) [@timshuwy](https://www.epiusers.help/u/timshuwy)\
**Post date:** [March 25, 2020, 4:44pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/3 "2020-03-25T16:44:08Z")

</div>

check out this site: [C# Split String Examples - Dot Net Perls](https://www.dotnetperls.com/split)  
you can insert any character into the split command.

---

<div class="post-metadata">

**Author:** ![ckoch](https://www.epiusers.help/user_avatar/www.epiusers.help/ckoch/32/32011_2.png) [@ckoch](https://www.epiusers.help/u/ckoch)\
**Post date:** [March 25, 2020, 5:25pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/4 "2020-03-25T17:25:12Z")

</div>

`Char3 = ttQuoteHedRow.ShipToAddrList.Split('~');` should do the trick, shouldn’t it?

Edit: except of course that returns an array. Silly me. OP, which element of the split up string do you need in Char3?

---

<div class="post-metadata">

**Author:** ![ckrusen](https://www.epiusers.help/user_avatar/www.epiusers.help/ckrusen/32/50584_2.png) [@ckrusen](https://www.epiusers.help/u/ckrusen)\
**Post date:** [March 25, 2020, 5:43pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/5 "2020-03-25T17:43:49Z")

</div>

Wouldn’t that return an array? Don’t you need to specify the specific element?

---

<div class="post-metadata">

**Author:** ![ckoch](https://www.epiusers.help/user_avatar/www.epiusers.help/ckoch/32/32011_2.png) [@ckoch](https://www.epiusers.help/u/ckoch)\
**Post date:** [March 25, 2020, 5:48pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/6 "2020-03-25T17:48:47Z")

</div>

Yes, of course. Silly me. I don’t know which element OP wants, either…

I just did this this morning on SalesRepList

---

<div class="post-metadata">

**Author:** ![timshuwy](https://www.epiusers.help/user_avatar/www.epiusers.help/timshuwy/32/90122_2.png) [@timshuwy](https://www.epiusers.help/u/timshuwy)\
**Post date:** [March 25, 2020, 6:20pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/7 "2020-03-25T18:20:25Z")

</div>

this should get you the elements:

```auto
string address1 = ttQuoteHedRow.ShipToAddrList.Split('~')[0];
string address2 = ttQuoteHedRow.ShipToAddrList.Split('~')[1];
string address3 = ttQuoteHedRow.ShipToAddrList.Split('~')[2];

```

or you can simply put it into an array:

```auto
string addressArray[] = ttQuoteHedRow.ShipToAddrList.Split('~');
int numberOfAddressLines = addressArray.Count();
foreach (string address in addressArray){
  // do something with address variable
}
```

---

<div class="post-metadata">

**Author:** ![LBARKER](https://www.epiusers.help/user_avatar/www.epiusers.help/lbarker/32/31072_2.png) [@LBARKER](https://www.epiusers.help/u/LBARKER)\
**Post date:** [March 25, 2020, 8:08pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/8 "2020-03-25T20:08:13Z")

</div>

Thanks Chris, I’m getting an error, I probably used the wrong terminology in my question

 ![image](https://epiusers.help/uploads/default/original/3X/f/7/f717202c393125f9426744a01ea08007e981da33.png)

---

<div class="post-metadata">

**Author:** ![timshuwy](https://www.epiusers.help/user_avatar/www.epiusers.help/timshuwy/32/90122_2.png) [@timshuwy](https://www.epiusers.help/u/timshuwy)\
**Post date:** [March 25, 2020, 8:24pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/9 "2020-03-25T20:24:12Z")

</div>

I see the problem… you dont need the first part of the statement. Instead, in the editor put the following:

```auto
ttQuoteHedRow.ShiptToAddrList.Split('~')[0]

```

you also dont need the semi-colon at the end.

---

<div class="post-metadata">

**Author:** ![LBARKER](https://www.epiusers.help/user_avatar/www.epiusers.help/lbarker/32/31072_2.png) [@LBARKER](https://www.epiusers.help/u/LBARKER)\
**Post date:** [March 25, 2020, 8:47pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/10 "2020-03-25T20:47:31Z")

</div>

@timshuwy , thats a lot closer to what I’m looking for, but it is only returning the first line of the Ship To address list

---

<div class="post-metadata">

**Author:** ![Rick\_Bird](https://www.epiusers.help/user_avatar/www.epiusers.help/rick_bird/32/77664_2.png) [@Rick\_Bird](https://www.epiusers.help/u/Rick_Bird)\
**Post date:** [March 25, 2020, 9:04pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/11 "2020-03-25T21:04:47Z")

</div>

Ok so Split isn’t what you want, you probably want to replace the ~ with a line return or something:

```
BpmFunc.Replace(ttQuoteHedRow.ShipToAddrList, "~" , Environment.NewLine)
```

---

<div class="post-metadata">

**Author:** ![LBARKER](https://www.epiusers.help/user_avatar/www.epiusers.help/lbarker/32/31072_2.png) [@LBARKER](https://www.epiusers.help/u/LBARKER)\
**Post date:** [March 25, 2020, 9:20pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/12 "2020-03-25T21:20:23Z")

</div>

@Rick_Bird, That throws this error

 ![image](https://epiusers.help/uploads/default/original/3X/c/6/c6c5334c879ad1cbf6dc3e9fec38c4bedec463b5.png)

---

<div class="post-metadata">

**Author:** ![Rick\_Bird](https://www.epiusers.help/user_avatar/www.epiusers.help/rick_bird/32/77664_2.png) [@Rick\_Bird](https://www.epiusers.help/u/Rick_Bird)\
**Post date:** [March 25, 2020, 9:22pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/13 "2020-03-25T21:22:13Z")

</div>

Double Click on the Replace function you have highlighted… it’s probably BpmFunc.Replace.

---

<div class="post-metadata">

**Author:** ![LBARKER](https://www.epiusers.help/user_avatar/www.epiusers.help/lbarker/32/31072_2.png) [@LBARKER](https://www.epiusers.help/u/LBARKER)\
**Post date:** [March 25, 2020, 9:44pm UTC](https://www.epiusers.help/t/bpm-c-split-string/65765/14 "2020-03-25T21:44:19Z")

</div>

Thanks @Rick_Bird , thanks all for your input

Ricks suggestion worked

BpmFunc.Replace(ttQuoteHedRow.ShipToAddrList , “~” , Environment.NewLine )
