LBARKER
(Lawson Barker)
March 25, 2020, 7:37am
1
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#
@LBARKER
i think what you need is in this old post!
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…
timshuwy
(Tim Shoemaker)
March 25, 2020, 4:44pm
3
check out this site: C# Split String Examples - Dot Net Perls
you can insert any character into the split command.
1 Like
ckoch
(Chris Koch)
March 25, 2020, 5:25pm
4
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?
ckrusen
(Calvin Krusen)
March 25, 2020, 5:43pm
5
Wouldn’t that return an array? Don’t you need to specify the specific element?
ckoch
(Chris Koch)
March 25, 2020, 5:48pm
6
Yes, of course. Silly me. I don’t know which element OP wants, either…
I just did this this morning on SalesRepList
timshuwy
(Tim Shoemaker)
March 25, 2020, 6:20pm
7
this should get you the elements:
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:
string addressArray[] = ttQuoteHedRow.ShipToAddrList.Split('~');
int numberOfAddressLines = addressArray.Count();
foreach (string address in addressArray){
// do something with address variable
}
2 Likes
LBARKER
(Lawson Barker)
March 25, 2020, 8:08pm
8
Thanks Chris, I’m getting an error, I probably used the wrong terminology in my question
timshuwy
(Tim Shoemaker)
March 25, 2020, 8:24pm
9
I see the problem… you dont need the first part of the statement. Instead, in the editor put the following:
ttQuoteHedRow.ShiptToAddrList.Split('~')[0]
you also dont need the semi-colon at the end.
2 Likes
LBARKER
(Lawson Barker)
March 25, 2020, 8:47pm
10
@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
Rick_Bird
(Rick Bird)
March 25, 2020, 9:04pm
11
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)
1 Like
LBARKER
(Lawson Barker)
March 25, 2020, 9:20pm
12
@Rick_Bird , That throws this error
Rick_Bird
(Rick Bird)
March 25, 2020, 9:22pm
13
Double Click on the Replace function you have highlighted… it’s probably BpmFunc.Replace.
LBARKER
(Lawson Barker)
March 25, 2020, 9:44pm
14
Thanks @Rick_Bird , thanks all for your input
Ricks suggestion worked
BpmFunc.Replace(ttQuoteHedRow.ShipToAddrList , “~” , Environment.NewLine )
1 Like