No -1 return value means “item not found”. You’re not finding your thing.
Thanks @keith, I could have sworn I read that -1 meant last item, which did seem odd to me at the time, but I must have read/recalled that wrong. Okay, at least I know that it must be something in my search. I’m still wondering though if I can have an expression in the List Item Expression itself, to output the index of the item, without having to use the JS to Bubble element.
Would be helpful to see the code in your LIE expression, @louisadekoya…
I removed the quotes around my var a expression and now it finds something, but it always comes back with 0. I add 1 to the value returned so actually I’m always displaying 1, whether it is the first or second item.
Thanks, @keith. I will put something on a clean page tomorrow and share if I don’t figure it out.
Zero would be first item in list (JS is zero based indices.). Found. (I guess.)
@louisadekoya You’re not getting much use of the LIE element, putting a list of texts in and pulling the same list out again.
Try using Expression instead …
['Search for Tasks’s unique id:join with "’,’"
'].indexOf('Current Page Task’s unique id
In the join with, put in
Thanks @mishav, as it happens I was just reading another of your posts clarifying the join with single quotes around a coma. Pretty sure that is the problem with my current ‘code’. I will give your expression a go. Many thanks.
Thanks @mishav, that works. So simple when you know how.
Nice discovery guys! It works with other things as well as user. I’d better put an example up.
I just figured this was an undocumented feature… are you saying you didn’t know it did that??
(If so… how does it do that automagically?)
Hi @mishav , just wrote an idea post Select app data types in API connector/API workflow so this feature might be implemented in API connector and workflows.
What is new about @mattmazzega’s discovery is only needing the unique id to reference a thing when returning an “app type” value from a plugin to Bubble.
Seems I should write up some documentation for you sometime!
(I always figured complex data types COULD NOT be returned and that those types in the drop down were just “there” as a side effect.)
Server script broken versions:
Edit - I had to do some funky workarounds for issues from the minification when publishing.
v1.1.3 New Version
- Server script - to run a Node script on the server, as a workflow step.
This will be handy if you don’t want to create a plugin of your own for server side code.
Calculations and string expressions, regular expressions.
Conversions between types, which has been difficult to do on the server side.
Set a value to be used by a subsequent workflow step.
I’ll be putting up some examples soon.
Note that you can run the script from a page workflow, the script will be run on the server, so you’ll notice a delay on the app as the client waits for the result.
The script will be stopped with an error after a timeout of 10 seconds.
Global variables aren’t reliably available – you can set them up, but there’s no guarantee that the script will run in the same process when you want to retrieve them.
There are a limited number of Node packages/modules available, Bubble has mentioned they will come up with a process for more to be added.
Caution - if you allow untrusted scripts to run, for example submitted by a user, it could break your app’s server scripting environment, and require intervention by the Bubble team.
Node objects and functions you may find useful.
Potentially useful functions:
Plus the documented functions assigned for a plugin:
Remember to refresh the app editor after upgrading a plugin.
Some examples of the server script:
New version 1.1.4
- Minor fix to List Item Expression, lookup() was barfing on null value.
How do I get the javscript to appear in my chrome debugger to step through it?