Authentication
When using NetServer, the CRMScript runs as the currently signed in user. For background tasks such as email import, scheduled tasks and data exchange (DBI), the script runs as a system user.Sentry will apply to your CRMScripts.
Agent and carrier software pattern
The agent and carrier pattern separates data from actions:- Agents govern actions
- Carriers are containers of content (data)
The following NetServer agents are not available in CRMScript
- AudienceAgent
- BulkUpdateAgent
- CRMScriptAgent
- DashboardAgent
- DatabaseAgent
- DatabaseTableAgent
- ErpSyncAgent
- EmailAgent
- TrayAppAgent
Agents
Agents are designed to handle a specific business area, for example, sale.- An agent represents a set of related service calls
- Each method on the agent corresponds to 1 service call
- Create a new agent.
- Use the agent to access 1 (or more) of the CRUD methods exposed by it.
- Set or get data.
- Save (if applicable).
CreateDefaultEntity()GetEntity(id)SaveEntity()DeleteEntity()
Declaration
CRMScript treats an agent as any other object, except agents don’t have a state. Thus, you need to declare each agent only once.Carriers
Carriers represent the data passed back and forth to the server by the agent. There are 2 types of carriers:- Simple read-only carriers
- Complex entity carriers
Read-only carriers (item carriers)
The simple carriers expose the properties of their content primarily as simple string values. In many situations, this simplicity is all you need and gives you the advantage of avoiding overhead. However, they can’t be saved back to the database!Whenever you want to add to or change the database, you must use an entity carrier.
Entity carriers
The complex carriers expose the properties of their content as objects, which are populated with more detailed data. They can be updated and stored back to the database.Declaration
Declared carrier objects are NOT initialized! This is especially important for objects that use enumerations, because those objects will contain illegal values. If you try to access them, NetServer will throw an exception. Use Get and Set to access attributes of entities.- Get methods return another carrier or a basic type
- Set methods take a carrier or basic type as argument