Data binding not recognizing an array

Wappler Version : 2.6.3
Operating System : mac 10.15

Expected behavior

An array should be recognized in the data bindings, even if that array is a simple array of strings, etc.

Actual behavior

The array is seen as text.

How to reproduce

It seems like arrays with objects work fine, but a basic array of values does not.

Screen Shot 2020-03-10 at 11.09.47 AM

Screen Shot 2020-03-10 at 11.10.15 AM

How did you define the array?

Server connect, split of a text string

And it just a variable in server connect that you split and output?

Yep…

OK well currently the set value action always returns a single text value. It is’n aware that you have split it to s string.

Some background info:

In Server Connect action steps produce output, but to know what structure the output is, we collect it from the step action information. So queries return their records, repeaters return what they repeat etc.
We have defined before hand what each action can return, so we can determine the output metadata without really executing the action.

So of course when you really execute the action you will see the final real result, but we can’t do that in design time as we don’t want to run your action and for example insert records to your database just to see what the output is.

So we try to define before hand as much as possible what each step returns and construct this way the meta data of the whole server connect action. The output metadata is then stored in the same file and used for all the data pickers later on.

We use actually the same technique on the client side with App Connect - but there we have a bit more advanced version as we keep track not only of the output data but also of each variable and also the transformations done by the formatters that modify the metadata output. So in App Connect we know what when you apply the split on string you get an array out.

Unfortunately even with this new technique in the App Connect pickers, we still haven’t found the optimal solution for getting the meta data out of an expression. Because you will have to really run each expression to the data formatter dialog that analyzes the expression and returns the metadata. But if you just type the expression in the data picker, we still don’t have the meta data.

Also the formatters in App Connect are really dependent on the data type they are applied, while in Server Connect you can apply them on anything and you are responsive to choose the right type.

I hope it makes a bit sense :slight_smile:

But the bottom line is that we need a way to define the meta data of the variable output step.
We can go the App Connect route, but as I said even there it has a limitation as you have to go trough the formatters dialog each time.

Maybe a more simple solution will be to allow you to pick the output type yourself. That will work for simple data types, but not for more complex ones.

For complex data types we do have techniques like the schema editor that we use with the API connectors. There you can define your own output schema (meta data)

So conclusion: maybe we should just add a define schema button in the set value step - so you can enter your own output schema that can be picked later :slight_smile:

2 Likes

Hi @George,

Continuing this…I have a series of server action repeats that produce arrays along with a custom query that also produces an array. However in app connect there are not recognized as arrays. Shouldn’t a repeat and a custom query always produce an array?

They are shown as arrays in Data Bindings, but in Data Formats they are not.

Can you help with what I’m missing?

Screen Shot 2020-03-30 at 9.08.33 AM

1 Like

I see the issue – the problem is that I am accessing these from Content Pages. Doing the same thing on the head page, everything works fine.

Can this be enhanced soon?

@George This hits me all day long. Any chance of addressing soon?

1 Like

Is there any immediate work-around to this problem? We’re doing pretty much the same thing - parsing a string of comma separated artefact IDs, and we need to be able to split and loop on this, but it doesn’t seem possible.

Does anyone know of a way to make this work?

1 Like

@George

Just tested and still an issue in beta 3 – arrays are not recognized in the data binding’s if the server connect is in a content page.

This is a pretty old topic but if you define an output schema with your server connect set value action - that schema will be used.

Otherwise we have no idea what your array looks like.

The tests I did today use a server connect api that uses simple multiple record queries. Are you saying it is not intended for this to work?

The array is recognized in the initial selection:

But then cannot be manipulated with collection modifiers:

Shouldn’t it show like this?

And again, this works fine in a layout, it just is broken in a content page.

I was referring to the set value arrays that you created with split.

Regular arrays should be just pickable and if the type is not recognized maybe type can set it from the type dropdown in the data formatter

Ahh, got it. I’ll retest and open a new issue if I still have problems.

1 Like