settablerow function in integration script errors in v4.5.1

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

dougbm
Ebase User
Posts: 8
Joined: Wed Jan 23, 2008 11:51 am
Location: Perth, WA, Australia

settablerow function in integration script errors in v4.5.1

#1

Postby dougbm » Tue Dec 17, 2013 7:02 am

Hi all

I've just deployed Ebase 4.5.1 and ported some integration solutions across from my 4.4 environment, and an integration script which was working in the earlier version is now returning the following error:

Error evaluating expression settablerow('TBL_REQUEST_FIELDS','TBL_REQUEST_FIELDS-NAME','ALL_COUNCILLORS') = 'OK' - Can only invoke this function from an online form

I note that 4.5.1 SP20131115 contains a fix for 'Null Pointer Exception in Java functions called from a server-side Javascript script', the problem log for which (ref. 335136) specifically references the settablerow function - is there any chance that the fix has affected my use of settablerow in integration (i.e. server side) scripts?

Many thanks, Doug
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Tue Dec 17, 2013 9:03 am

Doug,

You're right in your assumption - this fix seems to have caused another problem when using the functions from an integration service or workflow. We'll fix it in the next service pack. In the meantime, the only solution is to set the table row with a Javascript script then call this from FPL via callscript. Your Javascript script will look like this:

Code: Select all

var table = tables.REQUEST_FIELDS;
var row = table.findRow(table.NAME, "ALL_COUNCILLORS");
if (row != -1)
{
  table.setCurrentRow(row);
}
Regards
Jon
0 x

dougbm
Ebase User
Posts: 8
Joined: Wed Jan 23, 2008 11:51 am
Location: Perth, WA, Australia

#3

Postby dougbm » Wed Dec 18, 2013 11:50 am

Hi Jon (guessing that's Jon R btw - good to speak to you again :) )
Thanks for the tip. I've set up a JavaScript script as you suggest, but get the following error when it runs:

ERROR Can't find method com.ebasetech.ufs.runtime.external.api.impl.ApiTableBase.findRow(string,string). (CLRFRM_JS_SETTABLEROW#24)

The full script up to the error is below.
Cheers, Doug

Code: Select all

importPackage(com.ebasetech.xi.api);
importPackage(com.ebasetech.xi.services);

var table ;

switch(fields.STABROW_TABLE.value){
	case "TBL_REQUEST_FIELDS":
		table = tables.TBL_REQUEST_FIELDS ;
		break ;
//... other cases
	default:
		table = tables.TBL_REQUEST_FIELDS ;
		break ;
}

var column = fields.STABROW_FIELDNAME.value ;
var matchValue = fields.STABROW_FIELDVALUE.value ;

var row = table.findRow(column, matchValue);
0 x

dougbm
Ebase User
Posts: 8
Joined: Wed Jan 23, 2008 11:51 am
Location: Perth, WA, Australia

#4

Postby dougbm » Wed Dec 18, 2013 1:14 pm

More details: wondered if the problem was in the assignment of the 'table' variable, so I've changed the code to act directly on the tables.[table name] option, but the result is the same.

Code: Select all

var row ;
var column = fields.STABROW_FIELDNAME.value ;
var matchValue = fields.STABROW_FIELDVALUE.value ;

switch(fields.STABROW_TABLE.value){
	case "TBL_REQUEST_FIELDS":
		row = tables.TBL_REQUEST_FIELDS.findRow(column, matchValue) ;
		break ;
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#5

Postby Jon » Wed Dec 18, 2013 2:38 pm

Hello Doug,

the findRow() method takes a table column object as its first parameter which is the column that should be searched. So if the table TBL_REQUEST_FIELDS has a column COL1 it should be something like:

Code: Select all

var column = tables.TBL_REQUEST_FIELDS.COL1;
tables.TBL_REQUEST_FIELDS.findRow(column, "searchValue");
Regards
Jon
0 x

dougbm
Ebase User
Posts: 8
Joined: Wed Jan 23, 2008 11:51 am
Location: Perth, WA, Australia

#6

Postby dougbm » Thu Dec 19, 2013 12:12 am

Hi Jon
That is where I've been going wrong - I had 'column' as a string containing the required column name, not an object. When I explicitly set the variable to the column object the script works fine.
As you can probably guess, I'm looking for a way to make this process of looking up a row in a table (which I use ~everywhere~) generic by storing the table and column names and the value I want to match against in form fields then invoking one JS script which picks up on those values. Is it possible to substitute a value into an expression like

Code: Select all

var myTable = tables.MY_TABLE_NAME ;
One possible solution I guess would be to use eval():

Code: Select all

var myTable = eval("tables." + fields.MY_VARIABLE_TABLE_NAME.value) ;
var myColumn = eval("myTable." + fields.MY_VARIABLE_COL_NAME.value)
but everything I've read recommends strongly against using eval(), particularly in the latest version of ECMAScript.
Cheers, Doug
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#7

Postby Jon » Thu Dec 19, 2013 8:55 am

Doug,

Yes it's probably wise to treat eval with some caution, though you can use it when you can't find an alternative. In this case, you should be able to do what you want with the getTable() and getColumn() methods which take a string as argument e.g.

Code: Select all

function setTableRow(tableName, columnName, value)
{
  var tab = tables.getTable(tableName);
  if (tab)
  {
     var col = tab.getColumn(columnName);
     if (col)
     {
         var row = tab.findRow(col, value);
         if (row != -1)
         {
            tab.currentRow = row;
         }
      }
   }
}
These getXxx() methods exist wherever you get a named element e.g. fields, controls, pages, tables, resources etc. So you should always be able to make your code generic.

Regards
Jon
0 x

dougbm
Ebase User
Posts: 8
Joined: Wed Jan 23, 2008 11:51 am
Location: Perth, WA, Australia

#8

Postby dougbm » Thu Dec 19, 2013 1:19 pm

Hi Jon
Looks just the job, many thanks.
Cheers, Doug
0 x


Who is online

Users browsing this forum: No registered users and 3 guests