Querying in an expression, using datatype string

Is there a way to do a query in an expression using a string of a datatype, for example : “systemversions~n_systemchange#3c916451-d9fd-4bd4-8397-7de8e5fe0afc”.

Usecase: in the recordtype ExportDatasets, there is a plugin field called data_type. This returns a string like the one above. I want to then query the table of that recordtype.

1 Like

I’m not 100% sure this is an answer to your question.

That string can be used in an expression in places where you would normally use just the type name. So you can query for

systemversions~n_systemchange#3c916451-d9fd-4bd4-8397-7de8e5fe0afc:load(1).system.id

or

{systemversions~n_systemchange#3c916451-d9fd-4bd4-8397-7de8e5fe0afc,system.id,id.islower(10)}

Does that help? Or did you mean something else?

Yes I know this is possible, but I want to use it in an expression in the architect (could’ve been more clear in that, sorry)

Ah right, yes you can also do that, in processes. You can use the EvaluateExpression or (in some cases) ExpressionToolsEvaluateView actions from the Expression Tools plug-in for that as they accept expression strings.

You can build the expression string around the type name from the field with Concat blocks, for example

typename.concat(":count{").concat(typename).concat(",this}")

to get the number of records in such a type.

As a best practice, avoid using hard coded field and type names in such expressions, because the problem visitor and call tree will not be able detect that fields are being used there. (You can however use this, id, createdat, createdby, modifiedat, modifiedby, old(), load(…) and other default fields and functions.)

2 Likes

Thx a lot Wim! I will try it and get back to you

@Wim the proposed solution works!

I don’t know if this is on topic and if it’s allowed to continue on solved questions. Anyways:
I currently have and extra_where from a process using expressionstools plugin, but how does this string expression work in the application?

F.e. I have need to filter my incoming class (organizations in this case) on multiple conditions but it expects a string:

Hi @Jesse ,
What you have here is a String extensions plugin, validated expression field.
This field seems to be configured to contain an expression that evaluates to a string. The expression i can see in your picture evaluates to a list of contact records.
Here is a short explanation of the expression structure:
{
table_to_look_up, (in your case, contacts)
value_to_return, (in your case “this” means return record reference
where_condition (in your case you have 3 conditions, all of them which have to be true so you get a record)
}
then - the curly braces, means a list.

If your use case is the same as Joerie’s (you intend to put that expression into an EvaluateExpression action within a process, what you can do is to take the relevant part of the provided expression and wrap it in quotes. In this case, i assume you need the where part only, so you can modify the expression to:
“boolean:and([this.is_sales_contact.equals(yesno:load(1)), etc etc ])”
the " " would make it behave as a literal string which you can further pass into the EvaluateExpression as Wim described above.

1 Like

So it returned a string with “/n” in the string, which I removed now and hopefully this works. Thanks Miroslav :). ← This worked

Edit: Came back to give an update if this works.