Dataset as calculation result

Hi,

For technical reasons in some cases I want to have a dataset as a calculation result and I want to use the fields in my query on my form.
Now I created 3 calculations: One for the dataset and 2 for the fields I want to show. That is working:

function salesorder_nr()
{
	/** @type {JSDataSet} */
	var _dataset = dataset
	/** @type {String} */	                      
	var _value = _dataset.getValue(1, 1)                      
	return _value;
}

function dataset()
{
	
	var _query = 'SELECT salesorder_nr, REL.relation_code FROM salesorder SO \
					INNER JOIN relations REL ON REL.relation_id = SO.relation_id \
					WHERE salesorder_id = ?'
	var _ds = databaseManager.getDataSetByQuery('globis_development', _query, [salesorder_id], -1)
	
	return _ds
}


function relation_code()
{
	/** @type {JSDataSet} */
	var _dataset = dataset
	/** @type {String} */	                      
	var _value = _dataset.getValue(1, 2)                      
	return _value;
}

But what happens is that when calling the relation_code() calculation, the query is called. And also when retrieving the salesorder_nr(), then the query is called again.
I know that I can use a simple query for each field (so 1 query for relation_code and 1 query for salesorder_nr), but the above sample is only a very simple situation to make this situation easy to understand.

What I want in fact, is that the dataset is called only once (when showing the record on the form) and then I want to use the attributes that are in my dataset without executing the query again.

So if the dataset() calculation already has a value, then I don’t want to execute the query again, because the relation_code and salesorder_nr are already in the dataset.

Is there a way that I can check if the calculation dataset() already has a value, so that I can use the values in the dataset without executing the query again.
Because I want to execute 1 complex query once (for each record on the form) because this will give me the best performance.

I know this is not a very usual case, but I need this in some case (because I have to do a retrieve of those fields without the defined tablefilters). That is why I can’t use relations. And removing the tablefilters is neither an option.

I think this shouldn’t be done in a calculation. You experience already why…

Why don’t you use a form variable, for example, for your dataset and the other things you are doing here?

patrick:
Why don’t you use a form variable, for example, for your dataset and the other things you are doing here?

I can’t use a formvar here, because I need to show it in tableview

If Servoy would have the possibility to have an check box in the relation-definition “Ignore table-filter” then this would solve already lot of my problems.

Servoy: Could this be a feature that you would consider?

+1

Would be great in multi/inter company solutions. I now have to resort to dataset by query to ignore the table filters…

Now if we are going that way let’s add another feature request :

New optional parameter for databaseManager.getFoundset() : ignore tablefilter

Regards,

lwjwillemsen:
Would be great in multi/inter company solutions. I now have to resort to dataset by query to ignore the table filters…

In my case it is indeed an intercompany situation

lwjwillemsen:
Now if we are going that way let’s add another feature request :

New optional parameter for databaseManager.getFoundset() : ignore tablefilter

This could indeed also be useful

I created one request for both situations: #417899

Thanks, Martin.

Here is reply from Servoy:

Martin,

The table filters are a basic safety layer where all servoy-generated query resullts are filtered.
We think it is too risky to allow holes in this layer.

Alternatives are to use removeTableFilter() or, better, to have a admin-login role in your application that does not use filters and has access to all data.

Regards,
Rob

Thanks Martin for posting.

  1. Why was this Servoy reply not directly posted on this forum ?
  2. @Servoy : Do you have a nice and easy tool for inter company affairs where it is sometimes necessary to temporarily lift the table filter. This lifting is not user rights bound but business rules bound !

Regards,

lwjwillemsen:

  1. Why was this Servoy reply not directly posted on this forum ?

It was a reply on my feature request. So that is why I received the reply from Servoy directly

lwjwillemsen:
2) @Servoy : Do you have a nice and easy tool for inter company affairs where it is sometimes necessary to temporarily lift the table filter. This lifting is not user rights bound but business rules bound !

I’m thinking about using a headless client being called for intercompany transacties and that headless client will not use tablefilters.
But of course this is only a solution for headless clients operations.
I agree that this is not a user rights problem.
Tablefilters should always be applied, unless in some form/script we want to disable the tablefilters in particular situations.

Please create a case for that unstored calculation that is executed twice if you call it from 2 other calculations on the same record.
We should cache it, but now it seems that for unstored calcs this doesn’t happen. Those are always just executed when asked for.

jcompagner:
Please create a case for that unstored calculation that is executed twice if you call it from 2 other calculations on the same record.
We should cache it, but now it seems that for unstored calcs this doesn’t happen. Those are always just executed when asked for.

Case #418901 added. You can start implementing it :D :D :D

Johan,

Was something done with this request and was it maybe in 5.2.11?
Because I noticed a difference in behavior compared to earlier version (and unfortunately not a good behavior)

I also don’t see my case 418901 in the new support system.
Is that because it was fixed for you?

Martin

that one is was already fixed on 22 September

The problem was that if a calculation did call another calculation directly (and another one also did call that other calc) then it was always just calculated and never cached.
There is already a fix for that for a while now yes. That it always goes through the cache and never calls it directly

Johan,

Did you test it with my sample using a dataset as result?

Because it looks like that the cache is not working 100% like expected.
Before the change, the calculation was called multiple times.

But now it looks like it doesn’t result a dataset.

jcompagner:
that one is was already fixed on 22 September

OK, because it was not mentioned in the releasenotes of 5.2.11
And since I updated to 5.2.11 I don’t get result anymore

Martin

what type is does the calc dataset have?

It can’t be a string/date/number, it must be a media!

jcompagner:
what type is does the calc dataset have?

It can’t be a string/date/number, it must be a media!

Yes of course, it is a MEDIA type

I created a small sample that reproduces the situation. Case SVY-1167 added.