Copying Several Objects

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
john
Posts: 113
Joined: Tue Jul 25, 2006 10:48 am
Location: UK

Copying Several Objects

Post by john »

Hi

I have a quick question:

is it possible to create several new instances of a business object by copying several instances of old instances of the same business objects? I have mastered a situaltion where details from one instance of BO are copied to create a new instance of a different business object, but this only references one object. I have achieved this by findding (FIND) a particular instance of a business object and using CREATE to create a copy of that object CREATE NEW BO WITH FIELD1=OLDBOFIELD1, FIELD2=OLDBOFIELD2... etc etc. Would this still work if I referenced several instances of the object?

I hope that makes sense because it is very difficult to explain

Best Regards
John
aware_support2
Posts: 595
Joined: Sun Apr 24, 2005 2:22 am
Contact:

Post by aware_support2 »

Hi John,

Could you describe the business scenario you are trying to implement?
Aware IM Support Team
john
Posts: 113
Joined: Tue Jul 25, 2006 10:48 am
Location: UK

Post by john »

Hi

Thanks for the quick response. I wondered if it would be have been better going into more detail but I was trying to avoid a really long post (like this one) . . .

Anyway I digress

Basically I have a situation at the moment where our users (outside the company) submit personal details for temp workers. When they come accross to us they are READ ONLY to ensure we cannot change anything. The temps are used in another (payroll) system and are available to the agencies accross the internet. If they then want to change the details of a temp worker they need to submit a seperate business object called a change of details form. This has to be seperate so the Audit trail can be folllowed.
When an agency wants to submit a change of details, I have started off by running a search query, where the agency has to type the temps unique identifier to pull a particular temp into focus. The system copies all of the temp information from the original record and drops it into the change of details form. A process is started from the query that populates the change of details form
ENTER NEW COD WITH COD.TempID=Temp.TempID,COD.Name=Temp.Name . . . Using PAYEForm . . .
Every field is copied accross so the agency is presented with information that they can change, and the new form is submitted. We now have two temp records (in different business objects with the same temp ID). When we accept the change of details we select say 'Yes' for a paricular field to accept it and another process is started (this is the important bit)
This process creates a backup copy of the original temp record in another BO called ArchiveTemp, and the original temp record is overwritten with the information in the change of details form. Also by nature of the fact that I selected 'Yes' to the change of details being accepted this record also lives in a seperate 'Live Change Of Details Query' so we now have three records of the same temp, which is the original temp record, the change of details form, and the updated temp (which can be updated more then once - hence the need for this to happed):
Process Edit Temp
(LocateTemp) ; FIND Temp WHERE Temp.TempID=COD.TempID
(CreateArchive) ; CREATE ArchiveTemp WITH ArchiveTemp.TempID=Temp.TempID . . . (all fields copied)
(UpdateTemp) ; Temp.TempID=COD.TempID . . (all fields copied)

This all works fine and I am so impressed with what you can get this system to do when you spare a little thought. However, I have a new situation where I would like to take the idea a step further. Our agencies also use this system to place these temps week by week at there jobs and submit them to us (almost like a timesheet) showing us how many hours they worked and where they were and such like (the business object is called AssignmentSheet). The problem is as a lot of our agenies have a lot of temps which tend to work at the same places week in week out, I would like to provide a mechanism that would copy the previous weeks list of assignments and create the same list for the current tax week.
From the above idea I thought about say, finding all of the assignemts that exist in the previous weeks assignment sheet (instances of AssignmentSheet) and use the CREATE as above to create a new record for each, where I would manually enter the tax week for each record e.g.
FIND AssignmentSheet WHERE AssigmentSheet.TaxWeek=(e.g. current week - 1)
This will pull several records into focus, then
CREATE AssignmentSheet WITH AssignentSheet.TempID=AssignmentSheet.TempID, AssignemtSheet.TaxWeek=(e.g. current tax week)

Now my question is, with the first example, I can create a "Copy" of the original temp record by only pulling one record into focus, but I was wondering if the second example would technically work or not. I am unsure if when use CREATE, you are only telling the system to Create ONE new record, but I would actually like to create one for every record I pull into focus?

I am very sorry about the length of my post but I thought it maybe useful to explain what I had already done to try to get my point accross. Anyway I look forward to your response and thankyou for always taking the time to help out

Best Regards
John
aware_support2
Posts: 595
Joined: Sun Apr 24, 2005 2:22 am
Contact:

Post by aware_support2 »

> I was wondering if the second example would technically work or not. I am unsure if when use CREATE, you are only telling the system to Create ONE new record, but I would actually like to create one for every record I pull into focus?

The standard way to create multiple instances for other related instances is to use FOR EACH, for example:

FIND Client WHERE ...
CREATE ClientAlert FOR EACH Client WITH ClientAlert.Client = Client

In a situation where both objects are of the same type you may use an alternative approach:

FIND AssignmentSheet WHERE ...
CreateNewAssignmentSheet

Here, CreateNewAssignmentSheet is a process that takes AssignmentSheet as its input and has the following single rule in it:

CREATE AssignmentSheet WITH AssignentSheet.TempID = ThisAssignmentSheet.TempID, ...

The process will be executed for each AssignmentSheet instance found by FIND.
Aware IM Support Team
john
Posts: 113
Joined: Tue Jul 25, 2006 10:48 am
Location: UK

Post by john »

that looks so obvious when you put it like that. I Like the look of the FOR EACH, which I have to say I have never noticed before. I will have a crack at one of these

Thankyou so much

Regards
John
Post Reply