Share ideas, ask questions, and get feedback about developing for ProcessMaker

Moderator: amosbatto

Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
By alvinmactal
Hi I'm using processmaker 3.0
and i want to add options in my dropdown, but when i view I cant open the form.

here is my javascript codes.
Code: Select all
var opt = document.createElement("OPTION");
opt.text = "Contact by Phone";
opt.value = "phone";
Thank you
Hello alvinmactal,

Well, I am not really sure what is your study case or so you want to use it, but there are two ways that let you add options to your drop down box without using javascript and give you an easy way to populate it.

1.- You can use a SQL query from a table or from a PMTable in the control properties.
2.- You can insert static values by clicking on the options symbol ([]) in the control properties.

It would be great if you can be more specific about what you exactly want to do.

By amosbatto
As Andrea mentions, it is recommended to use SQL to populate the list of options in a dropdown box from a PM Table or external database. Alternatively, you can use an array variable created in a trigger to populate the list of options.

However, if you really want to do it in with JavaScript in a BPMN process in PM 3 and later, then you can use this code:
$('#dropdown_id').getControl().append( new Option(newLabel, newKey, defaultSelected, nowSelected) );

For example:
Code: Select all
$('#selectService').getControl().append( new Option("Accounting", "accounting", false, true) );
The problem will dynamically adding options to a dropdown is that if that if the Dynaform needs to be displayed a second time to the user (or a Process Supervisor), then any added options will be lost and the user won't be able to see the selected option if it was added with JavaScript.

The way to get around this problem is to store the added options in a JSON string in a hidden field and add the stored options to the dropdown when the DynaForm is displayed again. To see an example how to do this with JavaScript, import the attached DynaForm which can be displayed multiple times without problems.
(6.22 KiB) Downloaded 5 times
Send for clarification

Cost: Will you be using PM entrerprise or open sou[…]

SMS Gateway

Hello natesh, I have a Get ready to use integrate[…]

delete information after CSV export

thanks for your attention, i have some change on y[…]

Thanx again amosbatto... I'll re-check file permis[…]