4

I need to extract numbers from the a text in calculation stage in Blue Prism. The text is "Please take note of your order reference: 123" The number"123" changes every in each case, every time a new order has been placed. I need to extract the number from the end of this and into a data item. I am currently using:

Right("Please take note of your order reference:","3")and it is not working.

Any advise would be greatly appreciated.

Marek Stejskal
  • 2,615
  • 1
  • 17
  • 27
M.p
  • 41
  • 1
  • 1
  • 3

9 Answers9

2

I just finished the Developer 1 course for BluePrism and had the same excercise. I used this string:

ToNumber(Replace([Save ordernumber], "Please take note of your order reference:",""))

It removed the text from the string, replacing it with nothing (""), and then creates a number out of the data left in the string. And voilà, you have your ordernumber.

johwes
  • 21
  • 2
1

You can use a calculation step in Blue Prism to achieve this, and you almost have it right.

I assume you have the entire string including the order reference number, loaded to a dataitem. Let's call this dataitem [orderReference]

Right([orderReference],3) will then give you the last three characters in the string (which will be the numbers).

This only works if the order reference is always three digits long. Over time the order references will probably increase to be four or five digits, and you will still only get the last three.

To accomodate for this, you can use Len([orderReference]) to get the length of the entire string. Deduct 42 from the length (There's 42 characters before the numbers - I assume there's a space after the : otherwise it would be 41).

Simply use that number instead of 3 in the Right function.

Right([orderReference],Len([orderReference])-42)
MAhipal Singh
  • 4,220
  • 35
  • 53
1

So you have a unique identifier ":" before the value you want to return, you can use this to your advantage.

1) use an InStr function to find the position of where this unique character is within the string.

2) Use a Left function to return the characters up to and including the unique character.

3) from this we can then utilize the replace function to nullify the text you have just return leaving only the value you want.

4) chuck in a Trim function (good house keeping and cleaner data)

I have shown what I did below (using [Data1] as your string value), this was regardless of the message you receive before that value as long as you have a unique character it will always return the value (I realize I could have just said that in two words (it make it dynamic))

Trim(Replace([Data1], Left([Data1], InStr([Data1], ":")), ""))

hope this helps :)

Milad Rashidi
  • 1,026
  • 4
  • 14
  • 33
1
Replace("Please take note of your order reference:123",
  Left("Please take note of your order reference: 123",
  InStr("Please take note of your order reference: 123",":")),"")

Note : Use Data item instead of "Please take note of your order reference:123"..

Tobias
  • 652
  • 3
  • 12
1

Store your data in variable A=Please take note of your order reference: 123

Use Replace([A],"Please take note of your order reference:space","space ") THEN Trim it: Trim(Replace([A],"Please take note of your order reference:space","space ")) THEN convert to Number Tonumber(Trim(Replace([A],"Please take note of your order reference:space","space ")))

I had the same scenario ,AUD $ 234 I tried the above steps which helped me,best of luck!!

0
        string test = "Please take note of your order reference: 123";
        string digits = new String(test.Where(Char.IsDigit).ToArray());
        Console.WriteLine(digits);

**you can achieve this by using code stage, I have used C#. instead of printing the output to console load it to a data item **

0

You can use below statement in blue prism Calculation stage

Trim(Mid([Data2], InStr([Data2], ":")+1, Len([Data2])-2))
0

Using Replace():

Trim(Replace(AllTextInElement, "Please take note of your order reference:", ""))

Using Regex in code block:

ExtractedNumbers = Regex.Match(AllTextInElement, "\d+")
David Foley
  • 261
  • 2
  • 9
0
ToNumber(Replace([Order Reference], "Please take note of your order reference:",""))
Shree
  • 18,997
  • 28
  • 86
  • 133