2

I am trying to execute this code for a listbox but its not working, this gives me the error 500. If i directly write the @formula in listbox it works fine.

return session.evaluate("@DbColumn(@DbName(), \"viewName\", 1)").elementAt(0)

but if i write below code it works fine.

return session.evaluate("@Unique").elementAt(0);

I am working in xpages on Lotus Notes 8.5.3

NotesArt
  • 383
  • 9
  • 20

3 Answers3

5

You receive a 500er Error because the @DbColumn for SSJS has a parameter less than the "original" @DbColumn-Version which will be executed if you are using the evaluate method. For XPages, the option for caching and class got lost.

This is the syntax for the evaluate statement:

@DbColumn( class : cache ; server : database ; view ; columnNumber )

This is the XPages syntax:

@DbColumn( server : database , view , columnNumber );

And you have to use the native Notes @Formula syntax, f.e. use semicolons instead commas.

Sven Hasselbach
  • 10,455
  • 1
  • 18
  • 26
  • Thanks..but how can i execute this @dbcolumn then that i have in text format? – NotesArt Apr 01 '12 at 07:57
  • I don't know if i understand you correctly, but if so, you could do it like this: return session.evaluate("@DbColumn(\"\"; @DbName() ; \"viewName\"; 1)").elementAt(0) – Sven Hasselbach Apr 01 '12 at 08:04
1

session.evaluate works with original @Formula syntax, not with SSJS one.

So use @DbColumn( ""; @DbName; "view", column ) instead.

Frantisek Kossuth
  • 3,524
  • 2
  • 23
  • 42
0

Here is the solution: In SSJS you can code the following directly...

@DbColumn(@DbName(),"viewName",1)

If you want to do the same using the session.Evaluate(), then you can try the following.

//@DbColumn(@DbName(),"viewName",1) --> in SSJS
//@DbColumn( class : cache ; server : database ; view ; columnNumber ) --> in Formula using Evaluate

var colValues = "@DbColumn(\"\":\"\";" + @DbName() + ";\"viewName\";1)";

print ("colValues[0]" + colValues[0]); // will print @DbColumn( "":""; ServerName ; viewName; 1)
print ("colValues[1]" + colValues[1]); // will print @DbColumn( "":""; DatabaseName; viewName; 1)

return session.evaluate(colValues[1]) // It will return the expected value in listbox

Because @DbName() will return both the server name and the database name. Whereas we need only the database name. This is only for the current server. For different server we need to specify the server name. I hope this will help...!!!

flykarthick
  • 79
  • 1
  • 6
  • 14