MiguelOM
Posts: 12
Joined: Mon Sep 19, 2022 8:01 am

Working with conditionals in JSON files

Mon Sep 19, 2022 8:23 am

Hello!,

I am trying to create an installer (enterprise), and I don't know how to set a value into an appsettings.json depending on which DB configuration the user set up.

As ConnectionString changes depending on the provider, what I need is to set the value of ConnectionString key "DbConnection" on my appsettings according to the provider [PROVIDER_PROP] chosen by the user throughout the installation.

I have tried to add a new item into the ConnectionString section, and set a condition, but I need the same key name (DBConnection) in any case (SQL Server, MySQL or Oracle) and cannot do it.

Thanks in advance for your support.

Best Regards,

Miguel

Catalin
Posts: 6542
Joined: Wed Jun 13, 2018 7:49 am

Re: Working with conditionals in JSON files

Tue Sep 20, 2022 3:58 pm

Hello Miguel and welcome to our forums,

Indeed, you can not have the same name for a node.

However, you can work this around by using installer properties.

For instance, you can create two properties in the "Properties" page, like this:
properties.png
properties.png (14.08KiB)Viewed 3974 times

You can then configure your JSON file as it follows:
DBConnection.png
DBConnection.png (7.75KiB)Viewed 3974 times

This way, you can use the same name.

Now, of course, you need to condition each node so only one gets installed.

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

MiguelOM
Posts: 12
Joined: Mon Sep 19, 2022 8:01 am

Re: Working with conditionals in JSON files

Thu Sep 22, 2022 7:55 am

Thank you so much!

It was the first think that I thought, but I wanted to know if I could do this kind of conditions.

Best Regards,

Miguel

Catalin
Posts: 6542
Joined: Wed Jun 13, 2018 7:49 am

Re: Working with conditionals in JSON files

Thu Sep 22, 2022 2:36 pm

You are always welcome, Miguel!

Glad I could assist.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”