Reduce Fetched Data after API Input

image

Hello all i´m challenging the following issue.

I want to do an automated form which includes the Phonenumber.

Im fetching the phone number from an API. I recieve the number with countrycode. My form has the country code already set as constant.

For example: +44 123456789

I need to input only 123456789 but my fetch is 44123456789. Is it possible to exclude the first 2 digits in a simple way?

Im Using Studio X with HTML request. Fetching from json works great but i have to solve this issue.

This is my first API implementation. I just started with UI Path 2 weeks ago. It makes really fun and im lerning a lot.

Hi @Hugen_Dugen

Try this

Var1.Split(" ")(1)

I hope it helps!!

@Hugen_Dugen

If the input is 44123456789

then try

Var1.Substring(2,9)

or

you can try this also

Var1.Substring(2)

I hope you understand!!

Hi @Hugen_Dugen

Try using this Regex:

strinput= +44 123456789
Matches= System.Text.RegularExpressions.Regex.Matches(strinput,"(?<=\s)[\d]+")

Datatype of Matches is System.Collections.Generic.IEnumerable(System.Text.RegularExpression.Match)

Hope it helps!!

Thank u very muc. If i use this solution how can i etract it into my form?

Actually im using type info:

@Hugen_Dugen

Try this

JSONObjekt("activeActivations")(0)("phoneNumber").ToString.Split(" ")(1)+"."+JSONObjekt("activeActivations")(0)("phoneNumber").ToString.Split(" ")(1)

or

JSONObjekt("activeActivations")(0)("phoneNumber").ToString+"."+JSONObjekt("activeActivations")(0)("phoneNumber").ToString.Split(" ")(1)

sorry for my dumb questions. First of all thank u. But i have to use ur assign function as well or only the new Input for my json fetch?

@Hugen_Dugen
Try this:

System.Text.RegularExpressions.Regex.Match(JSONObjekt("activeActivations")(0)("phoneNumber").ToString, "(?<=\s)[\d]+").Value

Output DataType: System.String

Hope it helps!!

@Hugen_Dugen

You have to take an assign activity in that

Phone Number=JSONObjekt("activeActivations")(0)("phoneNumber").ToString.Split(" ")(1)

So the output of Phone Number is 123456789
Then you have to use this variable in your Form

@Hugen_Dugen

Have you tried this?

Thanks but this looks a bit to tough for me. I looked into but wasnt lucky.

@Hugen_Dugen

Try this

After assign activity take Message Box activity to check whether the output is correct or not

Im trying actually. But getting errors. I have to put the assign funtion under the deserilize json?

image

@Hugen_Dugen

Just hover the error and show me that

show the full expression in assign activity

@Hugen_Dugen

Create a variable Var1

sorry… but how to :slight_smile: never used this function

@Hugen_Dugen

Phone Number=JSONObjekt(“activeActivations”)(0)(“phoneNumber”).ToString.Split(" ")(1)

change the yellow marked

@Hugen_Dugen

Click on Create Variable
image

Then give Variable name and data type

image

then click ok to create the variable

@Hugen_Dugen

In right side write this

JSONObjekt("activeActivations")(0)("phoneNumber").ToString.Split(" ")(1)