JavaScript set value to linked multi select column

Good morning. I have a question, which I could not solve by checking the docs:

In a table, I have stations that are present and the usecases, each station works on.

In a second table, I do the employer processing and want to assign, which stations an employer has to contact, based on usecase.
But. I dont want to do it manually. I want to have a script, that sets the linked values, based on selected use case.

So, If I select “Entry”, like int he screenshot, I want an automation rule to fire a script, that gets me all stations that contain the use case “Entry” and then sets the links accordingly in the “ToBeDone” column.

Part one of the problem was simple and gives the desired results:

await bse.query('select Station from Stationen where UseCase has any of ("Entry")');

this returns:
[0: Object { Station: “numberOne” }
1: Object { Station: “Three” }
2: Object { Station: “Four” }]

But how to set those objects to the “ToBeDone” column?

Ok, I got it working. For those, who are interested:
Do not trust the documentation on the website, it is not up to date! I got plenty of “xxx is not a function” errors, for example for base.getColumns(“tablename”), which is obviously not there:
See base dump from console here:

Object { getActiveTable: getActiveTable(), getTables: getTables(), addTable: addTable(e), getTableByName: getTableByName(e), renameTable: renameTable(e, t), deleteTable: deleteTable(e), getActiveView: getActiveView(), getViews: getViews(e), utils: {…}, dtableStore: {…}, … }
viewDataGrid.chunk.8e359e05000b.js line 1 > Function:3:69

You see, no function getColumns(“tablename”) anywhere.
But on the website, it is mentioned:
This was only one example.

Dump base, table and other objects you intend to use in JS to console to see the currently implemented functions.

Without that, you will tear your hair out.

Now, for the sollution:

const bse = base; // I just wanted to go with another name here ;-)
var usecase = await bse.query('select _id from Stationen where UseCase has any of ("Entry")');
const tble_lfzttl =  bse.getTableByName('Processing');
//const columns = await bse.listColumns('Processing'); // return table's columns, check on console to retrieve link id
const linkId = "xxxx";

usecase.forEach(function(einArrayElement) { 
 //   console.log(einArrayElement['_id']); 
 bse.addLink(linkId, "Processing", "Stationen", bse.context.currentRow['_id'], einArrayElement['_id']);

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.