How to check fatching variable from inconfig has a value or not

how can I check that my “inconfig(MyVariable).ToString” is empty or has a value?

I tried with a simple if statement
if “inconfig(MyVariable).ToString” = “”
then
MyVariable = “MyTest.xlsx” - I have added as asign activity with a value
else
it will give the value from inconfig.

But its not working… I’m doing it because … if under testing process file I do not wanted to run whole process then i can run the file and it will use that assign value.

Hi @Ellen

Can you try like this

If String.IsNullOrEmpty(inconfig(MyVariable).ToString) Then
    MyVariable = "MyTest.xlsx"
Else
    ' Your code to use the value from inconfig
End If

Hope this helps!!

Hi @Ellen

Try this:

If String.IsNullOrEmpty(inconfig(MyVariable).ToString)
Then
    MyVariable = "MyTest.xlsx" ' Assign activity with the value
Else
    ' Do nothing or perform other actions with the existing value from inconfig
End If

Hope it helps!!

Sorry its not working… Giving this error

image

And its not going inside THEN loop.

@Ellen

What are you storing in MyVariable. Can you specify.

Regards,

I getting a folder path

@Ellen

What’s your exact condition you want to check. Specify

Regards,

You understood right her…

I have a folder path inside the inconfig file… When i run project form MAIN file its working… im getting the path in whole project.

Feks. I have 8 files in project and I got an error in 4th file. Now I just want to run that file to solv the issue. My inconfig will be empty as im not starting project from MAIN.

So i just wanted to create an IF statement which just check if inconfig is empty then it should go to assign activity and get the folder path from there.

You can use the following in the Condition of the If statement:

inconfig Is Nothing

It will evaluate to True if inconfig has not been initialized.

still getting same error…

image

image

after giving this error its not going inside THEN area.

Use this exact condition.

(Reasoning: your inConfig dictionary is not initialized and that’s why you get the null reference error.)

it is initialized…

everything is correct…
It giving right error that my inconfig is empty but then why its not going into THEN are?

@Ellen

It’s throwing you error because in your config file MyVariable value is empty that why.
Instead of removing that from the config file, try the below way.
→ Use Folder Exists activity to check whether folder exists or not. Store the output in a variable.
→ Use If acitivity and the the output variable of folder exists. If true,do nothing. If False, use assign to assign the folder path.

Hope it helps

No it is full … I rechacked it.

folder also exist…
folder path is correct
variable is also correct which has the path in excel

everything is correct.
No need to check weather folder has data or not but folder have 2 files.

@Ellen
Use the below condition in If

Directory.GetFIles(in_Config("Common Folder").ToString).Count>0

This will check whether you folder has files or not.
If yes, Do the rest of the workflow If no, Do the required process.

Regards,

This is not the issue…

The error is correct… as inconfig is empty because im not running project from Main.xml file…

I’m asking, how to go further from this error… means its correct that inconfig is empty… how do i implement so that it goes to the Assign activity?

As I mentioned, you need to set the Condition to

inconfig Is Nothing

Instead of

inConfig("FileFolder").ToString Is Nothing

As the workflow doesn’t get the input argument config dictionary from another workflow, the config dictionary will be null (Nothing). When it’s null, you get the null reference exception (“Object reference not set to an instance of an object”) when you try to get value for key “FileFolder”.

1 Like

Thanks a lot…
Now i understood… I thougth you said Use your inconfig statement and add is Nothing after that.

Now it works. Thanks a lot.

Are you good in groupby function?
I need help in that issue as well.

You’re welcome! :grinning:

As the groupby is a separate issue, I would recommend to create a new topic for it.

1 Like

Can you check that. Thanks