+1 vote

Hi,

with efficy 10 what would be the cleanest option, to block my users from using a test DB with a PROD custom and a Prod DB with a test Custom?

I ve several ideas here but what do you recommand me?

asked in Efficy/ Client side by (983 points)

1 Answer

+1 vote
Best answer

Hello Louis.

I saw two possibilities.

  1. Add environment name in SysStorage and harcoded mapping in custom. Error on difference.
  2. Compare custombase with DBAlias

I went for the last one, because in both cases when you would copy/paste the database and/or custom folder, you will forget at one point to change the configuration and might still work in PRD instead of DEV.

It is impossible however to create a duplicated custom folder or DbAlias. So my idea is to compare the DbAlias with the CustomBase folder. More specific, check if the DbAlias is contained in the custom folder name. If not, throw error.

This is the code I used.

MacroDashboardCustom.txt

DashScriptsCustom {[<%LoadScript(environment)%><%OnArgument(argvalue="%%GetCustomBase()", condition="contains", value="%%GetAboutInfo(DBALIAS)"
    ,else="<%Delay(1)%>RunScript(throwError, message=|WARNING, INVALID ENVIRONMENT!
    CustomBase <%GetCustomBase()%> does not contain DbAlias <%GetAboutInfo(DBALIAS)%>|)%>')%>")%>
]}

serverscripts/environment.js

function throwError() {
    throw Error(Arguments.Values("message"));
}

It will abort the loading of the dashboard and inform the developer or tester that he/she is mixing up environments.

Greets
Kristof

answered by (6.9k points)
selected by
Thanks a million Kristof, this is just what I needed.
1,173 questions
1,433 answers
1,726 comments
325 users