Trying to fetch value from get text element

Trying to fetch value from get text element also able to get successfully but sometimes when there is no value it’s giving error Exception : startIndex cannot be larger than length of string.
Parameter name: startIndex
Element where trying to get value : image
so value comes in highlighted part need before slash value & after slash value

Code written to get the value : str_Trans_Rate.Substring(0,8)

Any help would be appreciated here.

Use this expresssion in the assign activity where you have the above SubString expression

Str_Trans_Rate = If(String.IsNullOrEmpty(str_Trans_Rate.ToString.Trim),String.Empty,str_Trans_Rate.SubString(0,8))

Hope str_Trans_Rate is the variable obtained from GET TEXT ACTIVITY

This expression has to be used in a assign activity

It will first validate whether it has value or null value

If null value then it will assign a empty value
If get text has obtained a value then it will get SubString

Hope this would help you resolve this

Or

If you don’t want a empty value then use a IF condition and mention like this

String.IsNullOrEmpty(str_Trans_Rate.ToString.Trim)

If true it goes to THEN block where leave it empty and if false it goes to else block where use your current expression itself

str_Trans_Rate.Substring(0,8)

Cheers @mittal.abhishek

1 Like

Thanks for the solution Palaniyappan .

Actually i tried with 2 approach with IF condition but it was going into else condition then i put diffrent condition (Str_trans_rate.contains" / ") and finally it got worked.

Cheers@Palaniyappan.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.