ArrayList or util.list results to populate a AutoComplete

1
0
-1

Hi

Hoping you guys can help me I have a mssql connector the returns an array List the a 1000 results with a result that looks like

[ "100093", "BOLT,HEXHD 8.8 DIN931YZ", 24 ]
[ "19M8035", " CAP SCREW, ", 34 ]
[ "100510", "NUT, WHEEL (COLLAR) 26 TON CLASS8", 117 ],
[ "100720", "BOLT,HEXHD SAE8 BS2470 BL", 121 ]

The First "value"(100093) is the part number this is the value I want to show in the auto complete, then I want to have two Input boxes next to it that will fill with the Description of the part and the other on the qty so the user knows what that part number is.

Questions
Is arrayList the correct way to do this?
Currently i have an api calling the variable stock
../API/bpm/activityVariable/{{taskId}}/stock
What do i put into the available value to only get the part number
Currently have Stock.value but that returns [ "100093", "BOLT,HEXHD 8.8 DIN931YZ", 24 ]

Thanks for the help
Regards Paul

2 answers

1
+1
-1

I would probably use JSON as follows:

[{
        "idCode": "100093",
                "desc": "BOLT,HEXHD 8.8 DIN931YZ",
                "Qty": 24
}, {
        "idCode": "100093",
                "desc": "BOLT,HEXHD 8.8 DIN931YZ",
                "Qty": 24
}]

And then use code similar to this:

http://stackoverflow.com/questions/17201730/jquery-autocomplete-to-fill-in-another-field

See the ticked answer (3 votes) by stefanz

You probably will need to develop a custom widget to do it,

regards
Seán

PS: If this reply answers your question, please mark a resolved.

1
0
-1

Hi Sean

I am quite a novice at this so bear with me I need to call the variables from a a sql database as the part numbers and qtys are always changing.

Is there anyway to show and store just the 1st value of the array list the "part number"(if this is the right format to use Arraylist?) In the autocomplete avaliable values?

I'm, might be wrong but the code you put in above look like hard coding the numbers and that won't work for me, if I'm wrong please clarify for me "I'm a bit slow"

Thanks for the help

Regards
Paul

Comments

Submitted by Sean McP on Wed, 02/10/2016 - 08:05

First thing I suppose is what version Bonitasoft are you using 6 or 7?

If 6 ArrayList is fine if 7 JSON is much better.

For your autocomplete select box, for 7

just gett he numbers with

Select "partNo", "partDesc" from "listOfPartsTable";

then in a connector do something like:

import groovy.json.JsonBuilder;
List<object> parts = new ArrayList<Object>();

while resultset.next(){
def line = builder{
partNo = resultset.getString("partNo");
partDesc = resultset.getString("partDesc");
}
parts.add(line);
}
return parts;

From: http://community.bonitasoft.com/node/21600#node-21610

You then use parts in your autoocomplete select box.

to get the actual quantity (as you say always changing) you will need to have an onchange event for a completely recognized partNo, that uses ajax to interrogate the database for the quantity.

A lot of work...but the only real way to do it.

regards

Notifications