How to use a Development and Production Database with a SQL Request control

  • 12 November 2019
  • 5 replies
  • 0 views

Badge +3

We have a development SharePoint 2016 onprem environment that points to a development SQL Server database server. When we move our code to Production we do not want to have to modify the Nintex forms to change the name of the database server. Is there a way to have a database alias so that we can have dynamic coding based upon the SharePoint environment?


5 replies

Userlevel 6
Badge +22
Add the following formula (modified to suit your environment) to the server name field in the SQL request control.
fn-If(fn-contains(Site URL,"ProdSite Name"),"ProdServer","DevSever")
Tested and it works.

Badge +3
thanks, I just did a quick test and it did not work. is the syntax correct below? Also assuming the function is an if/else ?

fn-If(fn-contains(Site URL,"http://www.google.com"),"proddbdb1","devdbdb1")
Userlevel 6
Badge +22

Looks correct.
What happens if you cut it down a bit.
fn-If(fn-contains(Site URL,"google"),"proddbdb1","devdbdb1")
Test in a calaculated value control to make sure the formula is working.

Badge +3
Silly me, I was trying to test this via "Test Connection". After publishing the form and trying it, it looks like this works!

More tests tomorrow with my team.

I'll update the post to confirm, thank you @SimonMuntz !
Badge +3
@SimonMuntz we have fully tested this and it does work.

However after further discussions with the team we were able to find a better approach. We are using a Nintex constant that contains the database name. We will use the name of the Nintex constant in the SQL Request control. This gives us more options in case we ever need to change the SQL Server to another instance and allows us to make the change in one location that will reflect all forms.

Thank you for your help!

Reply