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
#784682
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";
getField("MyDropdown").options.add(opt);
Thank you
#814796
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.

Regards
By amosbatto
#814806
Alvinmactal,
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 9 times

سلام من راهنمائی می خواستم اگر یک گزارش با ابزار […]

ممنون از راهنمائی این کار را هم کردم در آخر مجبور […]

Hello, I have a form which has many subforms and[…]

Dynaforms with many fields

Good day, I have a dynaform with many fields (thi[…]