How can we generate unique Id without making any DB calls i.e directly from SAIL form

Certified Senior Developer

Hi ,

 

I have a scenario, where I have 2 buttons on my form: Add and Submit.

1) A user has to add details(say for example employee details) before submitting the form.

2)Use can add more than 1 employee details. Once these details are added they are displayed in a new grid in the same form.

3) Once the user clicks on Add button , the details get displayed in new grid, but at the same time I need to generate unique Id for each new addition. 

I will remain on the same form until and unless I submit it. Before submitting the form I need t generate unique Ids(say employee Id).

How this can be done from SAIL side. I do not want DB calls, as this might impact the performance?

 

 

  Discussion posts and replies are publicly visible

Parents
  • Does the Employee ID(s) have to be unique in relation to Employees that already exist in your database? If that is the case, I don't think there is a way to avoid doing atleast one database call to retrieve the max employee ID that already exists. Even if you decide to go with this approach, you can run into collisions if more than one user is attempting to add new employees (e.g. User A and User B initiate the action to add employees at the same time, they both do one query to grab the max employee ID which is currently equal to 10, they both end up creating an Employee with ID 11 at the same time).

    It might be simpler to display the IDs upon submission and display temporary IDs when the form hasn't been submitted. E.g. - Clicking Add Button displays details and "Employee 1"; or maybe you don't need to display an ID, you display the name of the employee instead (already included in details). Then when you submit you can display a confirmation screen which displays the newly generated IDs outputted from your write to (multiple) data store entity node.
Reply
  • Does the Employee ID(s) have to be unique in relation to Employees that already exist in your database? If that is the case, I don't think there is a way to avoid doing atleast one database call to retrieve the max employee ID that already exists. Even if you decide to go with this approach, you can run into collisions if more than one user is attempting to add new employees (e.g. User A and User B initiate the action to add employees at the same time, they both do one query to grab the max employee ID which is currently equal to 10, they both end up creating an Employee with ID 11 at the same time).

    It might be simpler to display the IDs upon submission and display temporary IDs when the form hasn't been submitted. E.g. - Clicking Add Button displays details and "Employee 1"; or maybe you don't need to display an ID, you display the name of the employee instead (already included in details). Then when you submit you can display a confirmation screen which displays the newly generated IDs outputted from your write to (multiple) data store entity node.
Children
No Data