How to use showLookupWindow methodToAddFoundsetFilters param

How to use the showLookupWindow methodToAddFoundsetFilters parameter correctly? The documentation only says:

param _methodToAddFoundsetFilters: the method where you can add foundsets filters to the lookup window foundset

I tried this:

function showFollowOnDocuments() {
	/** @type {JSEvent} */
	var event = arguments[5];
	var followOnDocuments = function () {
		foundset.addFoundSetFilterParam( 'referenzid', '=', id, 'follow-on documents' );
		foundset.loadAllRecords();
		foundset.sort( 'id asc' );
	}
	scopes.svyLookupWindows.showLookupWindow( event, null, 'Charter Fakturierung', null, followOnDocuments() );
}

but it does not work.

I think you have to pass a foundset in the function as a parameter and you have to return that foundset. Something like this:

function followOnDocuments(fs) {
      fs.addFoundSetFilterParam( 'referenzid', '=', id, 'follow-on documents' );
      fs.loadAllRecords();
      fs.sort( 'id asc' );
      return fs;
   }

And where you pass the function into showLookupWindow you have to remove the parentheses like this:

scopes.svyLookupWindows.showLookupWindow( event, null, 'Charter Fakturierung', null, followOnDocuments );

jdbruijn:
I think you have to pass a foundset in the function as a parameter and you have to return that foundset. Something like this:

function followOnDocuments(fs) {
  fs.addFoundSetFilterParam( 'referenzid', '=', id, 'follow-on documents' );
  fs.loadAllRecords();
  fs.sort( 'id asc' );
  return fs;

}



And where you pass the function into showLookupWindow you have to remove the parentheses like this:


scopes.svyLookupWindows.showLookupWindow( event, null, ‘Charter Fakturierung’, null, followOnDocuments );

I tried the 2 following approaches, that both doesn’t work:

function showFollowOnDocuments() {
	/** @type {JSEvent} */
	var event = arguments[5];
	var fsFollowOnDocuments = foundset.duplicateFoundSet();
	var followOnDocuments = function ( fsFollowOnDocuments ) {
		fsFollowOnDocuments.addFoundSetFilterParam( 'referenzid', '=', id, 'follow-on documents' );
		fsFollowOnDocuments.loadAllRecords();
		fsFollowOnDocuments.sort( 'id asc' );
		return fsFollowOnDocuments;
	}
	scopes.svyLookupWindows.showLookupWindow( event, null, 'Charter Fakturierung', null, followOnDocuments );
}

In the above case, I get the warnings: “Parameter fsFollowOnDocuments hides a variable” and “The function showLookupWindow([JSEvent],String,String,[String],[String],[Object],[Array],[String],[Boolean],[String],[String],[String],[String]) is not applicable for the arguments (JSEvent,null,String,null,Function)”. So tried tried the following too:

function showFollowOnDocuments() {
	/** @type {JSEvent} */
	var event = arguments[5];
	
	var followOnDocuments = function () {
		var fsFollowOnDocuments = foundset.duplicateFoundSet();
		fsFollowOnDocuments.addFoundSetFilterParam( 'referenzid', '=', id, 'follow-on documents' );
		fsFollowOnDocuments.loadAllRecords();
		fsFollowOnDocuments.sort( 'id asc' );
		return fsFollowOnDocuments;
	}
	scopes.svyLookupWindows.showLookupWindow( event, null, 'Charter Fakturierung', null, followOnDocuments );
}

Then I get this warning: “The function showLookupWindow([JSEvent],String,String,[String],[String],[Object],[Array],[String],[Boolean],[String],[String],[String],[String]) is not applicable for the arguments (JSEvent,null,String,null,Function)”

The parameter has to be a string, I forgot the quotes:

scopes.svyLookupWindows.showLookupWindow( event, null, 'Charter Fakturierung', null, 'followOnDocuments' );

I’m not sure your approach will work, i’m using it slightly different:

/**
 * @param {JSFoundSet} fs
 *
 * @properties={typeid:24,uuid:"5796CE89-9660-42C7-ABCF-89C688C6A859"}
 */
function getFilters(fs){
	fs.addFoundSetFilterParam('object_address','LIKE','Ring%')
	return fs
}

And I’m calling it like this:

function doLookup() {
....
scopes.svyLookupWindows.showLookupWindow(event, 'object_id', 'Object', 'afterInsertObject','getFilters')
...
}

Yes, you are right, it has to be passed as a string and it can’t be an inner function, because it can also be passed through the properties of a button for example. I call it from the framework toolbar, so I found out that the event that has passed to the lookup window function has to be an event from the form. So I passed also the return form parameter, but in this case, the function is called but it shows no lookup window.

I tried:

function showFollowOnDocuments() {
	// wrong event
	/** @type {JSEvent} */
	var event = arguments[5];

	scopes.svyLookupWindows.showLookupWindow( event, null, 'Charter Fakturierung', null, 'getFollowOnDocuments', null, null, null, null, null, null, 'boss_char_charterfaktura_base_dtl', null );
}
function getFollowOnDocuments( followOnDocuments ) {

//	followOnDocuments.addFoundSetFilterParam( 'referenzid', '=', id, 'follow-on documents' );
	application.output( id );
	return followOnDocuments;
}

but I get no “id” output.

and what is id supposed to be? Where is that value coming from?

jdbruijn:
and what is id supposed to be? Where is that value coming from?

It should give me the document number from the currently selected record. It’s a dataprovider from the form in the lookup window and it’s on the form where call the lookup window.

that is strange.
If getFollowOnDocuments a function is on the form where you call the lookup than you should be able to access the foundset of that form.

jdbruijn:
that is strange.
If getFollowOnDocuments a function is on the form where you call the lookup than you should be able to access the foundset of that form.

Yes, but the problem is that the “getFollowOnDocuments” is not called. Is the method not called, because the lookup window can’t get the foundset?

have you tried stepping through showLookupWindow? Maybe there is another condition that is preventing you entering that function.

jdbruijn:
have you tried stepping through showLookupWindow? Maybe there is another condition that is preventing you entering that function.

Yes and the showLookupWindow function returns at this point.:

} else if (_returnFormMode == 'browse' &&(!globals.nav.program[globals.nav_program_name] ||  !globals.nav.program[globals.nav_program_name].noreadonly)  && !allowInBrowse) {
	return // not allowed in browse mode
}