Extract Client ID, Name and Country from WI details (ACME System1)

Dear colleagues,

I can extract only the entire block of text (3 rows) using the Get Text activity and the output string variable is ClientInfo.
How would you suggest to extract individually Client ID, Name and Country?

I think I should use Split to seperate per rows (0, 1 and 2) and then for each row to use Substring to extract the part after space.
… but I don’t know how :frowning:

@Cardon_Cezar Can you give a Try on this :

  1. Assign ClientID = System.Text.RegularExpressions.Regex.Split(Split(Split(ClientInfo,“:”)(1),“Client ID”)(0).Trim,“\n”)(0)

  2. Assign ClientName = System.Text.RegularExpressions.Regex.Split(Split(Split(ClientInfo,“:”)(2),“Client Name”)(0).Trim,“\n”)(0)

  3. Assign ClientCountry = Split(Split(ClientInfo,“:”)(3),“Client Country”)(0).Trim

Output the Assigned variables in a Message Box or a Write Line and Check the values appear properly or not.

6 Likes

First split the get text output string with this below code,
ArrStr(String array type) = InputStr.Split( Environment.NewLine.ToCharArray)
Then use below code to get the value,
ArrStr(0).Split(“:”.ToCharArray)(1).Trim

3 Likes

Haii@cardon_cezar Extract a specific part from a long string
Refer this one,

2 Likes

Hi @supermanPunch,

I am referring to the generating yearly report assignment.

I am facing the problem to extract the TaxID from the ACME system.

I tried to use your code with my variable. The Get Text has been assigned to ClientInformation and I would like to extract the first row (TaxID) value. Here is the screenshot:

However, uipath showing there is an error with the code. I cannot detect where is it.

Besides, may I know what does the (0) means at the end of the code?

Thank you.

@Sam_Kong Can you Show us what is the error that you get ? (0) Means that you are selecting the First Element after Splitting the values into an Array.

Hi @supermanPunch

Here is the error:

This is the code that I used to extract the TaxID but was not successful.

I have also tried other code but still having the same error message.

@Sam_Kong Try this :

  1. Assign TaxID = System.Text.RegularExpressions.Regex.Split(Split(Split(VendorInformation,“:”)(1),“TaxID”)(0).Trim,“\n”)(0)

  2. Assign Name = System.Text.RegularExpressions.Regex.Split(Split(Split(VendorInformation,“:”)(2),“Client Name”)(0).Trim,“\n”)(0)

  3. Assign Address = System.Text.RegularExpressions.Regex.Split(Split(Split(VendorInformation,“:”)(3),“Address”)(0).Trim,“\n”)(0)

  4. Assign City = Split(Split(VendorInformation,“:”)(4),“Client Country”)(0).Trim

Where VendorInformation is the Output of Get Text Activity.

Thank you for the reply.

Here is the error message:

The code I used to run to extract the TaxID is as follow and the output of the Get Text activity is ClientInformation

Is it possible for me to sent my project for you to check? Thank you.

@Sam_Kong Yes

Hi @supermanPunch,

I just sent an email to you. Please check it.

Thank you.

@Cardon_Cezar

Thank you. It is working but i would like to know what actually “Client ID” split does in this expression coz i just gave xyz instead of client id but still i am getting the client id value
Your expression
Assign ClientID = System.Text.RegularExpressions.Regex.Split(Split(Split(ClientInfo,“:”)(1),“Client ID”)(0).Trim,“\n”)(0)

system.text.RegularExpressions.Regex.Split(Split(Split(str_GetAccountInfo,“:”)(1),“xyz”)(0),“\n”)(0)

Could you please explain this expression?

in 1st split i understand we are fetching QS86336 ClientName and in second split we are applying only on the result of the first split so the result does not contain client id then how split with “Client ID” would work
Thanks,
Ula

@Boopathi To retrieve Client ID, it Should have been Splitted with Client Name, and to Retrieve Client Name, it Should have been Client Country.

Actually with the value “xyz”, it doesn’t Split accordingly, But since it takes the first Element after Split, Still the Content remains the same, and at last due to the Split based on Newline, It correctly extracts the Needed value.

I think there is a Correction needed in that post :sweat_smile: , But since it worked properly i couldnt recognise the error

Thank you. Could you please post the correct one?

@Boopathi Extraction Should always work with these Expression :

  1. Assign ClientID = System.Text.RegularExpressions.Regex.Split(Split(ClientInfo,“:”)(1).Trim,“\n”)(0)

  2. Assign ClientName = System.Text.RegularExpressions.Regex.Split(Split(ClientInfo,“:”)(2).Trim,“\n”)(0)

  3. Assign ClientCountry = Split(Split(ClientInfo,“:”)(3),“Client Country”)(0).Trim

1 Like

@supermanPunch Thank you.

1 Like