I have two forms with two entities in one screen.
1. Job Information
2. Job Tasks
- 1 Job information may have many tasks, once saved a job information(left), job tasks can be created (right), and saved tasks will be shown in the bottom as a table list.
- I have created "Copy" button on the main page for saved Job information, and I can only copy the job information at this moment, May I know how can I copy the relevant related 'saved job tasks '(another table) together in the logic? Kindly advise the logic with the attachment. Thanks.
Attaching OML for your reference. Hope this helps.
My bad, I missed to update the job info id column. Here add this assignment in clone job task action. It will work.
Hi @Winnie Lam,
1. Create the copy action
2. Create a Common server action function with an input parameter to set the data type of the master table ID.
3. Create a join between the two tables using the id as a filter. Retrieve the data from the Entity and use a for each loop with a condition. Finally, place the create function of both entities.
4. You can now copy the data.
Thanks&Regards,
Naveen Kumarasamy
Hi,
You can do the following steps:
1. On copy click action, create an input parameter and pass the Job Information Id (create a local var in screen and assign this value).
2. You can add an aggregate for Job Task on your screen (set on demand). Add filter inside as JobTask.jobId=local var (which hold the current Job Info Id at step1). Refresh this aggregate on you copy on click action. This aggregate will give you the list of tasks for that Job Info Id.
3. You have already added the logic on copy click action to create a copy of this Job information (Got the new Job Id). Using for loop (List will be your aggregate in step2), create the job tasks and map the job info id as the new Id which is generated.
Hope this helps.
Would you mind to provide a simple oml attachment for my study? cuz I am new here and still learning in progress.
Seems it can clone the job info only, can still can't clone the job detail.
It works now. Thank you so much.
Sorry, I just found another problem with the copied record,
If I copy the job that has more than 1 job task, relevant records are generated repeatedly with same job ID and Job TaskID, and if I delete any job tasks of a record will result in deleting another one too. Please help.
Job ID 43 has two job tasks (task ID 77, 79), when I click "copy",
Two record are generated with same (Job ID: 48 is generated twice), if i delete any task in one of the records, another one will be deleted too.
- However, only one record is shown in db for the Job.
If there are three job task for one job, two Job record with same Job ID are generated. Kindly help.
Hi Winnie,
For me Job Info id col was set to IsAutonumber as Yes(which means automatically the Id will be generated when we create a new Job. Which is why If you see second screenshot, I did not had Id column binding). Check on your end if Job Id column is not set to IsAutonumber Yes and you have separate logic to generate the unique Id then in the below Create action , you need to assign the Id column to generate new unique ID.
Let me know if this clarifies. If not, then you can share you OML, I will check what is the issue.
Sorry for my late reply, plz refer to the interface Job Test and JobTestDetail2. Probably there is some error for "Save" logic ?
I have created 2 job tasks for JobID 58, but two same record are generated in the list.
If I create 3 job tasks for one Job ID, 3 same record are generated on the list.
Hi Winnie, your code to clone the job maintanenace2 and job detail looks fine. But recommend you to cleanup your code and correct your table structure(Job detail has two foreign key reference one with job maintenance and another with job maintenance2 )
1. Remove this aggregate from join(JobTest screen), there is no need for this. And I hope you using Clone action (as your copy job action is not correct)
2. Regarding your statement- However, only one record is shown in db for the Job. -It is happening because of wrong join conditions on aggregates on screen used for table list. Suggest you to test your aggregates because of which duplicate records showing on listing (remove unwanted joins)