Can't get list things into server scripts in backend workflow toolbox

Cant get list properties into my server script on backend workflows.

To test I made a really simple example. Please help if I’m missing something.

Here’s a list.

And I’m scheduling a backend workflow and passing in that list

Passing the list to my server script

But it’s not there

Am I doing something wrong. I’m having no trouble doing this exact same thing on the front end, but on the backend it’s not working for me.

here’s the list in server logs

1 Like

I can get single properties (Thing 1, Thing 2, etc) in there no problem.

Hi @dschmid00 :wave:

Try to change the expression from “list_of_numbers” to “list_of_numbers:each item number:formated as text” (delimited by commas) as your Thing list 1.

okay. This was just a test because I encountered the issue with a significantly more complicated type and I just made this to test if I could get a list of simple numbers, but I’ll doing what you suggested now.

1 Like

So “list_of_numbers:each item number:formated as text is not possible

list_of_numbers:formated as text is not a list but I can pass it into the single parameter options and make it back into an array. It would be nice though if I could use the lists, because that’s going to be hard for my more complex types.

1 Like

@mishav please

I don’t get it :sweat_smile:

image

This is not what you expected?

nope that’s for the single items. What you’re seeing there is a single string. I’m trying to get values out of the thing list below. Which I can do when using this on the front end but not on the back end.

You can transform this string into an array/list and use it anyway. Just place this code inside your server script prompt:

var my_list= [];
if (properties.keyvalues[1].value != null){
var my_list = properties.keyvalues[1].value.split(',');
}

Hope it help!

Hi @dschmid00 and @rpetribu

I’ve added some examples here: example editor page

The examples wrap the result in JSON.stringify because the output is put onto a text group.

// list of numbers in thinglist1
// list of numbers does not have listProperties
var len = properties.thinglist1.length();
var result = [];
for await (const item of properties.thinglist1) {
  result.push(item);
}
return (result); // result is array of numbers
// list of books in thinglist1
var len = await properties.thinglist1.length();
var result = [];
for await (const item of properties.thinglist1) {
  // result.push(item.listProperties());
  result.push(await item.get("title_text"));
}
return (result); // result is an array of titles

The docs did not cover this adequately, I’ll update them.

Edit - I’ve updated the docs params-bubble and params-vanilla

1 Like

Thanks it work. Really appreciate the help and the additional examples. :slight_smile: Only thing is the list input is not visible as an input in my server logs.

1 Like

Something else that would be amazing if you could include it in the docs is how to access properties on nested objects.

on the front end I could chain .get() to go into another object and then get the field I cared about.
image

On the backend, no amount of await seemed to make this possible and I had to put two lists in and do this.


image

I’m sure there’s a way to do it in one, but after trying for a couple hours I took the easy way out.

1 Like

@dschmid00 that’s a good workaround!

I’ve updated the docs, added another example to the section params-bubble

(The cached time on the docs CDN is kinda long, to refresh the page cache: open the site, turn off network, refresh page to get error, turn on network, refresh page and should be the new one not the cached one)

I also added another workflow “list of books categories” in example app editor

var len = await properties.thinglist1.length();
var result = [];
for await (const item of properties.thinglist1) {
    // result.push(item.listProperties());
    result.push(await item.get("title_text"));
    var cat = await item.get("category_custom_category");
    // result.push(cat.listProperties());
    var catname = await cat.get("name_text");
    result.push(catname);
}
return result; // list of text

I hope this proves useful! :slight_smile:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.