[Tip of the Week] Getting Started with Arrays

hello all,

using Arrays unlocks a lot of very interesting functionality in Tulip; you can populate drop downs with Arrays, you can process information sent in Arrays from Connector Functions, you can use them to easily loop through information.

but to get started, you first need to understand how to create an Array (at least from an App). to do so, all you need to do is use the Arrays > Push onto Array Action in a Trigger. here’s a quick guide:

create a Text Input to add to your Array:

add a Button with a single Trigger that adds this element to the Array:

displaying the Array in your app, you can see that there are multiple objects of Text that can be contained within an Array:

are you using Arrays in your Apps?? if so, share how you’ve been using them here below!!

I’m using connector function to get data from SQL database. In connector function I’m returning one column:

I would like to use this data for Single select widget for various purposes - selected value used for filters, etc.

You mentioned that Array can be sent from Connector Function. I’m unable to achieve that functionality.

I’m running Connector function on step enter trigger and then I would like to push result into array. Looks like variable type is not correct to push it into array.

Can you please provide correct steps to push values from db into array.

Thank you,
Ermin

hello @ermingut, are you storing the Output of the Connector Function as a Variable or as an Array in your App (if you could send a screenshot of the Variables Modal that would be great)?? thanks!!

I’m not sure if this it what you mean:

yes, this is indeed what I was looking for!! the reason why you’re not seeing that option in the Trigger you shared here is because it’s already an Array and that’s expecting a regular String.

if you navigate to the Single Select and go to the Options, do you not see ProductionLineTypeIDs as an option?? similar to: Pass the connector result to App input drop down list options - #2 by gio.

I can see that ProductionLineTypeIDs is filled with correct data.

But unfortunately I can not see this variable as option to Single select

Here is workable solution:

My Connector function returns single string from database like (SQL rocks :slight_smile: ):

C80;GIANT Mod. 2018;GIANT Old;Partena;Ulhmann X10;Ulhmann X20

And then on step enter i have following trigger:

I can use array_test as Single select widget data source.

Thanks.

great, happy to hear it @ermingut!!

the reason you weren’t seeing it here is because it’s an Array of Objects, rather than an Array of Strings which is what the Single Select expects.

I agree that SQL rocks, as does Tulip!!

1 Like

Maybe a little follow-up.

So as mentioned connector function only returns object. And this can be used for various purposes thru the app.

While solution we found is good for my needs, I would like to know if is it possible to return array of strings from connector function? (to solve @Ruijia problem)

Ermin

Hi Ermingut,
May i know how you set ‘array_test’, if also try to follow your solution. Seems still not working for me… Thanks.

This is kind of type of database dependent.

I have simple table in SQL db:
image

and query below returns IDs in one column:

SELECT REVERSE(SUBSTRING(REVERSE((select Id+’;’ from CodeLists.ProductionLineTypes for xml path (’’))), 2, 9999)) ProductionLineTypesIDs

Regards,
Ermin

Hi Ermin,

If you want to get the IDs, i think you are directly getting the ID ‘Select ID from Codelists. ProductionLineTypes’ from DB connector, right?

If so, i put the similar query as you. But when i try to use the function ‘Split’,

I could only put split(@Variable.Query1 ,’;’) but from example, seems i should put split(@Variable.Query1. Deparment_Name,’;’) ?

But the function doesn’t support this syntax? not sure if you could point out my error point?

So appreciate if you could share all the settings/captures from your end if possible?

Thanks.

I’m returning all the IDs in one string column with ‘;’ separator: