Hi everyone, I'm developing an app with few process and I need to make CRUD functions. Basically, I have a BDM Object 'Customers' and I need to add a Edit feature. I know that all update process have to do trough a Process, but I can't found clearly how I have to design the process in order to get an external persistenceId, fill the form with that info, allow to update some fields and save it. Can anybody help me with this? Or share a example of something like that? Thanks in advance!
Hi,
One possible solution is to:
- Create an
Update Customer Info
process with a instantiation contract gathering:
- A persistenceId (of type TEXT) or a unique key from your entity (eg:
Customer
has ausername
attribute which belong to a unique constraint in your data model) - The “editable” information (password, firstName, birthDate…etc).
- Add a business variable
customer
to this process with a default value expression like this:
def customer = customerDao.findByPersistenceId(persistenceId.toLong()) // persistenceId is a contract input
//or
def customer = customerDao.findByPersistenceUsername(username) // username is a contract input
// Update object attributes with contract values
customer.password = password
customer.name = name
…
return customer // The updated instance will be persisted
HTH
Romain
Hello ,
1) The first time user submits a data from through form, you dont need persistenceid. It is auto created and inserted into database.
2) When you want to edit the same info that was submitted , you can retrieve the persistenceId from database and use the method findByPersistenceid to fetch the row and then perform CRUD operation on it.
Inside the operation , you can write something like
def dbref = MyTableDAO.findByPersistenceId(persistenceid)
dbref.column1 = value1
dbref.column2 = value2
return dbref
regards
Thank for you quickly response Roy!, ok, just another question, how I have to make the process? I have to do an empty process (without tasks) and the start form have the form structure for update the fields or the process still must have a inner task to do it? Thanks in advance!
Usually , you should design a system in such a way that User submits a request and its forwarded to Multiple approvers.
In case any Approver rejects the requests, then you can put a task for the requester to Edit / modify and resubmit inside the same process. Edit and Modification does not require a seperate process. It should be a task for the requester.
Does your scenario include that Requester can Modify at any time ??
Create a process. Keep only 1 Service task. When user submits the form, trigger the process and update the database.
This will be treated as a case in the portal for the process.
Regards
Thank for you quickly response Romain!, ok, just another question, how I have to make the process? I have to do an empty process (without tasks) and the start form have the form structure for update the fields or the process still must have a inner task to do it? Thanks in advance!