Url-open

Hello,
in Url-open widget, how can we put the correct environment in the url.
we have 4 environments. right now, we hardcode but when we move to production, we have to change the url again. is it a way to do dynamic url.
thanks,

Eddy

1 Like

You would need to use a condition and checkā€¦ Pretty sure I saw a post earlier that mentioned pulling the app serverā€¦

If you are only interested in production vs non production situation, there is a condition for that.

Other alternative is configure your BPM to use user codes then you just change your user codes rather than having to edit the BPM

One way to do this is to use UDCodesā€¦ you can create your own UD Code table, and put the value in thereā€¦ then you look up the UDCode and get the URLā€¦ you would have the URL be different in each environment, but he UDCode would be the same lookup value. This gives you a place to store ā€œconstantsā€ that change between environments.
Back in the olden days, we would create a field in the company or site table, but this is not as easy as a UDCode.

However, if you copied live to pilot, for example, the UDCode would have to be updated before one used it. Having a function that runs at startup could update that code. @Asz0ka identified the app server URL that you can use in Functions or Directives:

this.Session.AppServerURL
3 Likes

Note that there is also a ā€œproductionā€ flag in the company table that tells if this is the production system. Your bpm could check that flag and only do production things when the flag is on, and not do production things when it is offā€¦ we added this for the cloud, but I believe on-prem can use the same feature.

1 Like

Iā€™m sure I found that on another post :sweat_smile:

1 Like

Hello Guys,
i found it. it is {%session.context.appServer%}
but how can I put indexof in the condition expression

thanks,

Eddy

Same issue with this as Mark pointed out with the UD Codes suggestion, this flag is stored in the db not with the app server

Hello Guys,
finally, I fixed the issue.
it is not bad.
step 1, add row-update
in the epibinding: TransView.Server. Value is ā€œ%session.context.appServer%ā€

step 1, add condition
in the expression you put ā€˜{TransView.Server}ā€™.IndexOf(ā€œpilotā€) > 0
in the true, you put the url-open ā†’ pilot url
in the false, then add the condition, you repeat the same step.

regards,

Eddy

2 Likes

Could you also take the part of the URL after the server and instance and just append that to %session.context.appServer%? That way you wouldnā€™t need the if then else logic. Just a thought.

thanks Mark,
our url to open is external url.
thatā€™s why i need if else.

regards,

Eddy

Gotcha. I didnā€™t know it was an external URL or what the format for it was. I try to avoid hardcoding instance information whenever I can since I may add a dev instance or have a special project that isnā€™t contained in all of the if else logic. I might use C# string interpolation to get around it.

Hello Mark,
if we can use string.format(ā€˜{0}ā€™,xxx), it will be great.
do you have an example how to do it in a url_open.

thanks,

Eddy

Not without knowing the url format.

http://bbbpilot.com/abc/
http://bbbthird.com/abc/
http://bbbfourth.com/abc/
http://bbb.com/abc/

regards,

Eddy

I would create a transview variable called serverInstance. I would only need to a reliable way to determine whether or not youā€™re in production, since there is no suffix in your external url. You would then set serverInstance to blank and in all other cases, you would set it to the instance name. Leaving actual syntax aside for a moment, the code would look something like this:

# Split appServer name by the backslash, which would give you an array of strings (may have to adjust the index if the double back slash gets escaped)
# [0] = "https"
# [1] = ""
# [2] = "server"
# [3] = "instance"
# The following will set the serverInstance to blank if it's production otherwise it will return the instance
serverInstance = appServer.Split("//")[3]  == "Production" ? "" : appServer.Split("//")[3] ;

# now use interpolation to set the url
url = "https://bbb{serverInstance}.com/abc"

Thereā€™s some interpolation ā€œ{}ā€ already in Kinetic, so you may have to play around with the syntax to do the interpolation within Kineticā€™s interpolation.

2 Likes