Company class instead of the NSContactAgent class. The Company class is a CRMScript datatype, and it is more efficient than NetServer when used directly. The same goes for the Customer, Ticket and Message classes.
Using a NetServer entity is more expensive than using a CRMScript entity. When you use a NetServer entity, the system must send a request to the application server through proxy classes to fetch the entity. This does not happen when using a CRMScript entity.
When there is no other option, and you must use a NetServer agent, there is one key point to know when saving an entity: for each child entity only the child entity ID value is required.
Simplified example
The following code invokes two agent methods, sending two distinct requests to the application server,DocumentAgent.CreateDefaultDocumentEntity() and PersonAgent.GetPerson().
That is inefficient code. The correct approach is to:
- create the
NSPerson - set the person ID value
- assign the person to the document entity
DocumentAgent.CreateDefaultDocumentEntity().
The call trace for the above code is as follows: