How to add a composite key in joget form.

Confluence User - 09 Sep, 2016

Hi

I have a requirements in which a record should be uniquely identified by multiple fields. How to add a composite key in joget form?

Regards

Touqeer

forms;workflow;userviews;database

3


12 Sep, 2016
confluenceUser
confluenceUser

Hi,

I think you can connect directly to the database table e.g. using MySQL Workbench for MySQL, to add the composite key directly in the corresponding columns to enforce your requirement.

 

13 Sep, 2016
confluenceUser
confluenceUser

Hello, Applying a unique key constraint from MYSQL is last option to me, because I don't want to do any thing from backdoor. If possible then it would be batter to achieve from joget. Thanks,

23 Sep, 2016
confluenceUser
confluenceUser

Hi Touqeer Khan,

I imagine this combination would work:

  1. Use Custom HTML with Javascript to concenat the fields and put the new value in a additional joget text field.
  2. You can either
    1. call the new textfield "id" 
    2. call the new textfield something like "composite_id" and use the Update Database Plugin (for example as  post-submission tool) if you want this to be your new unique id that joget uses for the "Foreign Key" reference

However, this should be done in the first step of the process or at least before the original id is used for any other database table as a foreign key. 

I haven't tested this but I imagine it should work.

---

An alternative is to leave the original id what it is, store the key generated by javascript in a "composite_id" field and then use JDBC load and store binders to select database rows by your new composite id field. for example something like:

Select * From app_fd_multirow

Where c_composite_id = '#form.process_table.c_compsite_id#'

for the JDBC Load Binder

This would also make sure that exporting / importing your app in a different environment still works without having to temper directly with MySql.

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print