Config File_Date

I have this in config file as Date_Filter

DateTime.Now.AddDays(-3).ToString(“dd/mm/yyyy”)

In workflow I have imported argument as

Assign activity

Filter_date = in_config(“Date_Filter”).tostring

Now the issue is its not executing formula in workflow. Instead it’s shows as

“DateTime.Now.AddDays(-3).ToString(“dd/mm/yyyy”)”

Or

“DateTime.Now.AddDays(-3).ToString(“\dd/mm/yyyy\”)”

Tried executing this in immediate window these are the results.

Moreover also tried replace in the workflow but nothing works.

Any leads will be appreciated

you cannot bypass compilation and externalize code in configs

we could inject from the config:

  • the days offset
  • the format string

and inject this as variables

You can’t put expressions in the config file. You would just put the number -3 then use it in the expression in the code: DateTime.Now.AddDays(CInt(Config("Days to Add").ToString)).ToString("dd/mm/yyyy")

What is Cint here…can you please advise also if you can share the xaml on this much appreciated… tried all this at my end. This isn’t working

So we can do for the offset

we convert the string from config into an int32 value

what in detail was done? Just share with us, what was placed within the config and how it was used afterwards

For RnD and Prototyping the immediate panel can be used
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

1 Like

@Sucess_for_Everyone,

Config file:

Code:

Now.AddDays(CInt(in_Config("Date_Filter").ToString)).ToString("dd/MM/yyyy")

CInt is to convert your “-3” string to use in calculation of how many days you want to substract or add.

Output:
image

Sample Code:
Workflow2.xaml (10.4 KB)

Thanks,
Ashok :slight_smile:

1 Like

HI Ashok, does this work flow work similarly for outlook automation where in we have to retrieve emails for last 7 days… so say If I want to retrieve the emails containing subjects such as “MY” “HOME” “WORK”, and this MY , HOME and WORK also has to be pulled from config file. Currently the code which is passed is : @SQL=(urn:schemas:httpmail:subject LIKE ‘%Q1_Filter%’) AND (urn:schemas:httpmail:subject LIKE ‘%Q2_Filter%’) AND (urn:schemas:httpmail:subject LIKE ‘%Q3_Filter%’) , however also needs to include the last 7 days to it… and all has to be pulled from config. is there a possibility for it.
image

@Sucess_for_Everyone,

Yes it will work similarly for mail filter as well.

Before we get divert to another topic could you please close this by accepting the solution and create new topic for this another query? I will be happy to help.

Thnaks,
Ashok :slight_smile:

CInt converts a string to an integer.

Share what XAML? It’s an expression. Store the number in the config file and use it in the expression. I’m not saying put that expression into the config file. You just put the number (ie -3) in the config file.

in output i am getting results as “28/05/2024”. tried replacing “”, but not working any suggestions

Getting that output from what expression? Show us your expression.

for this

That’s because you have .ToString(“dd/MM/yyyy”) - that defines the format of the output. You can make it whatever format you want.

1 Like

Thank you much appreciated

I am getting the same result under “” whereas for the sample given above with same result don’t have “” (quotation)

Don’t copy/paste from the forums. The double quotes will be the wrong character. Type the expression. You need to do that anyway for the imports to be done correctly.

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