I have a process that runs at Admin initialization time.
Among other things it creates a number of RegularUsers.
Code goes like:
If NOT(EXISTS RegularUser WHERE (RegularUser.LoginName='sp1')) Then
CREATE Conact with Contact.FirstName='John', Contact.LastName='Brown'
CREATE RegularUser WITH RegularUser.AccessLevel='SalesPerson',RegularUser.LoginName='sp1',RegularUser.Password='sp1', RegularUser.Contact=Contact
I make a number of different users of different types.
Problem is that they all have the same Contact record - the first to be created. This is also true if I use ThisContact. If I use ThatContact they get set to the second created contact record.
If I do a FIND for the specific record, hoping that this would clear the other contacts from the context, nothing changes.
Am I doing something wrong or is this limitation of the system?
thanks,
Terry
context problem
-
- Posts: 595
- Joined: Sun Apr 24, 2005 2:22 am
- Contact:
Terry,
This happens because all objects created by the process are accumulated in the context. When the system needs a Contact to assign to a RegularUser it pick up one from the context, which happens to be the first one.
You have a couple of options. One is to create each pair of objects in a separate process. All of these separate processes can be called from the main process. When each of these processes finishes the context created for that process is discarded, so when the next one starts it will have the context copied from the main process.
The other option is to import objects from files rather than create them in a process. There would be 3 files to import: Contacts, RegularUsers and the relationships between them. The relationship file contains attribute values that uniquely identify instances to be linked, for example:
RegularUser.LoginName, RegularUser.Contact.FirstName, RegularUser.Contact.LastName
'sp1', 'John', 'Brown'
and can be imported by the following rule:
IMPORT RELATIONSHIPS OF RegularUser FROM 'c:/user_contact.csv'
This happens because all objects created by the process are accumulated in the context. When the system needs a Contact to assign to a RegularUser it pick up one from the context, which happens to be the first one.
You have a couple of options. One is to create each pair of objects in a separate process. All of these separate processes can be called from the main process. When each of these processes finishes the context created for that process is discarded, so when the next one starts it will have the context copied from the main process.
The other option is to import objects from files rather than create them in a process. There would be 3 files to import: Contacts, RegularUsers and the relationships between them. The relationship file contains attribute values that uniquely identify instances to be linked, for example:
RegularUser.LoginName, RegularUser.Contact.FirstName, RegularUser.Contact.LastName
'sp1', 'John', 'Brown'
and can be imported by the following rule:
IMPORT RELATIONSHIPS OF RegularUser FROM 'c:/user_contact.csv'
Aware IM Support Team