Home > Forum > Rules, JS, SQL > JS for adding new row in item list

JS for adding new row in item list
0

Hi community!

We want to add new row(s) to an item list due to customer requirement.

This should be triggered on button click, that means on the client-side.

Unfortunately I didn't find a way, to insert new row(s) to an item list in available JS functions.

Does anyone know how to do that or could you provide some code samples?

Thanks in advance & best regards, Nik

MVP

Hi Nik,

there's this function:
webcon.businessRules.subelementAddNewRow

Unfortunately you can't populate the new row with the same call. You need to find the latest /unpopulated one.

General hint with a little trap:
If there's a form rule for this, you can also do it with JavaScript, just select the form rule action, and click on "show". This way you can look at the generated JavaScript and look for the relevant part.

Best regards,
Daniel

In reply to: Daniel Krüger (Cosmo Consult)

Hi Nik,

there's this function:
webcon.businessRules.subelementAddNewRow

Unfortunately you can't populate the new row with the same call. You need to find the latest /unpopulated one.

General hint with a little trap:
If there's a form rule for this, you can also do it with JavaScript, just select the form rule action, and click on "show". This way you can look at the generated JavaScript and look for the relevant part.

Best regards,
Daniel

Thanks for your response Daniel, but if you take a look at the generated Javascript from form rule,
I personally don't think this is a safe and future proof way to go ;-)

We took a look at the 'Change item lists values', which seems a good way to go, but this requires a global menu action to be invoked from Javascript,
which also saves the form and generates a new version.

But this is no problem for us so far.

The only problem here is the SQL query, which should take a JSON array from UI element and create table for adding new rows to item list, but this does not work either.

I will create a new thread for that, maybe there is a solution or workaround here.

Thanks agaon & best regards, Nik