String format method

Hi all, in my requirement am extracting the below matrix format,

matrix

and converting into the into the excel sheet with all currencies from the datatable as following

But from that data table, “I need only two currencies or one currecny (say ONLY USD,GBP or only one currency USD )”.

Using “string format method”, can I know how to implement!?

Thanks in advance.

1 Like

Hope this can be done using Linq

datatable.select("[To Currency]=‘USD’ or [To Currency]=‘GBP’")

from this we can get array of data row.

In my requirement, the customer need only one currency or two currencies @pathrudu. So how I need to write query dynamically!?

some times can it be more than two?

Yes @pathrudu.

You could probably achieve this with an array and putting each value in the array as a variable in the dt.Select method as @pathrudu advised.

For example:

Client requires USD and GBP. Have the currency array set up as USD;GBP (or USD,GBP) as long as the delimiter is constant. Then split into an array with Split(yourList,";"c) <- if the delimiter is a semi-colon.

Then in a for each loop, perform the dt.Select method on the original data, and for each array of datarow output you could add to a new datatable. I haven’t played around with it but you would need to initialize the datatable first and it depends on whether you want the headers in the new, filtered datatable. You won’t be able to use the .CopyToDatatable method as this would overwrite anything already in there.

Using an array for the currencies in this way would ensure the process can run correctly whether the client has requested any number of different currencies in any combination.

To use a variable in the dt.Select method it would be something like

datatable.select("[To Currency]=‘"+yourVariable+"’)

If in a for each loop with the currency array, if you set your ‘item’ to ‘currency’ for example:

datatable.select("[To Currency]=‘"+currency+"’)

This way you would only have to write it out once.

Thanks for the reply @KEntwistle. But sorry, can you explain your point once again.CurrencyExchangeNew.xaml (21.0 KB)

Asset or config file, enter the currencies your client wants to see.

CurrencyArray(var type: string) = USD;GBP;AUD

At the start of workflow, split this into an array.

yourArray(var type: array of string) = Split(CurrencyArray,";"c)

For each Currency in yourArray
DatarowArray(var type: array of datarow) = yourDatatable.Select("[Column Name]=‘"+Currency+"’)
Add to datatable activity: (DatarowArray into yourNewDatatable)

This should loop 3 times, as there are 3 currencies to grab from the main datatable.

The new datatable variable will need to be initialized (new system.net.datatable I think off the top of my head?) because you are not grabbing it from a range.

This new datatable, once filled with the relevant rows of data, can then be written elsewhere or manipulated further. It has been filtered based on the currencies your client requires.

Apologies if my explanation is lacking - I’m not very good at putting code into words!

Ya Thanks @KEntwistle. Can you once look into the xaml file, which I have tried.

It’s difficult to understand what you are trying to do because I don’t have context of the process.

You can achieve the dynamic currency requirements by playing around with the arrays, my solution won’t fit yours perfectly but some form of it should be suitable.

Also please review the values left in your variables as I believe you have just accidentally given me your email and password.

Oh yes!!.. I will take care of it.

In the above assign activity, am writing manually the currencies using string format method and the “transaction item” has all the currencies. How can I get which ever currency the client need?

It would be better if you maintain the currencies required by client in config file.

I have given all the currencies in the config file @pathrudu ,

@sushmithaelluru

hope this will help you…

BlankProcess1.zip (31.7 KB)

regards,
Pathrudu

Ok @pathrudu, am getting the below error.

Thanks.

This might be because i developed on 2018.3 version.

TypeArgument for ForEach is System.Data.DataRow

Activity: Invoke Method
TargetObject: newDT
MethodName: ImportRow
parameters

please let me know if you have any queries?

Ya, @pathrudu, which activity do I need to install for that error ?

it’s not necessary to install any activity you may need to re-do the process. please see the screen shots for the activities you are missing this may happened due to version difference. as you already have for each and invoke method activities.

One doubt @pathrudu, re-do the process mean?