User Rights ( Filter ) with LDAP / "Finetune"

My problem is just i want the result of this:

“C_NO IN (SELECT DISTINCT CAMP_NO FROM LDAP_GROUP_RIGHTS WHERE
GROUP_NO = (SELECT cn FROM LDAP_GROUPS WHERE gidNumber = '” + session[‘Login.gidNumber’] + “’) )”;
in the variable ant not the SQL itself. So the SQL would only be called once.

How can i cal this SQL and store it in a variable?

The easiest solution - in the onUnknownSqlMacroIdentifier event handler try to get the SessionVariable_camp_filter item value from the session. If it is not empty then just use it. If it IS empty - calculate it, store in the session and then use it.

And here is the local SQL call sample:

  var users = lda.selectSQL('SELECT * FROM Users');
  log(users.count);

You can find more about the lda object here: http://old.wiki.remobjects.com/wiki/LocalDataAdapter_Object_(Business_Rules_Scripting)

The example is not working for me… Sorry.

log(‘+++++++++++++++++++++++++++++++++++++++++’);
// var SessionVariable_camp_filter = lda.selectSQL(‘SELECT C_NO FROM CAMPS’);
session[‘SessionVariable_camp_filter’] = ‘Hello’;
log(‘SessionVariable_camp_filter: ‘+session[‘SessionVariable_camp_filter’]);
log(’+++++++++++++++++++++++++++++++++++++++++’);

When i uncomment the Line var SessionVariable_camp_filter ( and comment the line ession[‘SessionVariable_camp_filter’] = ‘Hello’; ) i get the following Error:

You fall into the endless recursion here.
In the beforeGetData you try to retrieve some data. And this attempt also triggers the beforeGetData event where you again call lda.selectSQL which triggers beforeGetData event and so on…

There is a check for this in the Scripting engine preventing the server app from failing with SctackOverflow in such situations

Take a look at the isNestedEvent property: http://old.wiki.remobjects.com/wiki/Global_Object_(Business_Rules_Scripting)

You need to check for it before triggering lda.selectSQL for a second time.