Evaluating an Expression

Hi, I´m trying (In CODELESS) to pass an expression as a text to a custom function that has to evaluate it and return a result.

Basically i have several tables I need to go thru and link, so I want to create a function that I can call with different inputs depending on the tables.

So I pass the Parent Table and the Child Table and I loop thru them one by one, evaluating some expression that is also passed to the FN and if true then create the relation.

And assuming there is a way to do this, how should I structure my matching clause such that in a text description I can access properties of both objects being compared? For example the matching clause might be:

PaymentDate (of child object from child table) > ReservationDate (of parent object from parent table)

hello @Christopher_Muscat_Azzopardi
create custom code evalMethod


and use it:

Cool thanks! And how should I structure my matching clause such that in the expression to evaulate I can access properties of objects being compared? For example the matching clause might be:

PaymentDate (of child object from child table) > ReservationDate (of parent object from parent table) AND Client (from Parent object) IS NOT ‘andrew’

Basically I need to be able to evaulate for example the following thing with a true or false return:

TEST childobject.date > parentobject.date AND parentobject.name != 'andrew’

Thanks

Hello @Christopher_Muscat_Azzopardi

You need to pass the variables into the custom code

However, I do not recommend you to use such an approach because of security issues, since this is CloudCode there should not be any eval (that executes JavaScript) that received code from the client.
Someone can send any JS code in the matchingclause parameter and do whatever.

Basically I need to be able to evaulate for example the following thing with a true or false return:
TEST childobject.date > parentobject.date AND parentobject.name != 'andrew’

As I understand you want to use our WhereClause syntax to filter loaded data, but it’s not possible because the syntax is used on the server to compose a query to DataBase.

Option #1
So if you need a couple of cases I would recommend you create a HashMap of these operations and then use it in a CustomCode

Option #2
Or you can build the whereClause then send it the server and finally receive already filtered result

Regards, Vlad