Limit the ammount of characthers shown in a select field or double select

Hi There,

If you use select in Sc you can’t set the ammount of characters that will be shown. Some of my records have a long text and i wan’t to limit the aamount of characters shown in the searchfield. so i use

SELECT LEFT(
brixx_kerntaken.kt_id, sc_concat(kt_crebo," | “, kt_kerntaak,” - ", kt_omschrijving_werkproces) ,40)
FROM brixx_kerntaken
ORDER BY kt_crebo, kt_kerntaak, kt_omschrijving_werkproces

that doesn’t work

also is there a way to get a search field with double select. a new field that truiggers teh double select field to filter doesn’t work because the values that are already in the record will not been shown (if they have another search value
any sugesstions

I don’t see a good way to limit the number of characters, but you can make the field itself short and it will only show the entire text when they drop down the select.

Occurred to me you can also make a second table that only has the first 40 characters and use that for your lookup.

SELECT LEFT(
brixx_kerntaken.kt_id, sc_concat(kt_crebo," | “, kt_kerntaak,” - ", kt_omschrijving_werkproces) ,40)
FROM brixx_kerntaken
ORDER BY kt_crebo, kt_kerntaak, kt_omschrijving_werkproces

Don’t use sc_concat(), use the native MySQL function CONCAT(), it should work fine


For the double select you can use an UNION to add local field to the search

SELECT xxx FROM
(
SELECT Field1, Field2, Field3 FROM xxx

UNION

SELECT {Field1}, {Field2}, {Field3} FROM anytable LIMIT 1
) T
WHERE xxx

You may have to add DISTINCT

thanks @jlboutin60
CONCAT did the trick…

for those who seek the answer, here’s mine

SELECT
brixx_kerntaken.kt_id, concat(kt_crebo," | “, kt_kerntaak,” - ", LEFT(kt_omschrijving_werkproces,150))
FROM brixx_kerntaken
ORDER BY kt_crebo, kt_kerntaak, kt_omschrijving_werkproces

the UNION i’m not so sure if that’s what i’m looking for.

you see. some values are already in de field. When you use a second field as a search field and filter the double select, the values that are already in the record saved are not shown (that’s obvious) but when i select other values and save the whole record field will be overwritten and my original values are not merged but gone bvecause they have not selected.
if the values are shown.
i’dont want the user selct the already chosen valaues select again.

Can you save your data as they are modified on your form or you need to wait for the user to save the form.

You can use the javascript change event on each field to call nm_atualiza(‘alterar’), to keep your database updated

Also you can modify your Double Select manually in beforeInsert or beforeUpdate

hi @jlboutin60 ,

the problem appears when a user select new values form the double select with a filter option. when you update the record, all the values are overwritten and the new selected values will be saved. this is how it should work.

the values already in the field, that where not shown because of the filtering are not saved.

so everytime when you filter a double select field, it shows only a part of the result, that fine, but when saving the record only those shown and selected are saved.

Hi @rotrax

I think your only solution is the UNION, that way you present in the double select all field already in the DB + the current one not already saved

yeah i think your right. I think i put a suggestion to scriptcase to alter this. when you do a many to many relationship you get a search function with it that does this standard. but a many tot many form the same table gives problems.

thanks again.