Class NSPersonAgent
Person data services.
Syntax
Examples
NSPersonAgent agent;
agent.callMethod(arg1, arg2);
Constructors
NSPersonAgent()
Person data services.
Introduced or updated in version: 7
Declaration
NSPersonAgent
Examples
NSPersonAgent agent;
agent.callMethod(arg1, arg2);
Methods
AddBounce(String)
Adds a bounce count on the email address if it exists
Introduced or updated in version: 8.5R08
Declaration
Void AddBounce(String emailAddress)
Parameters
Type | Name | Description |
---|---|---|
String | emailAddress |
Returns
Type | Description |
---|---|
Void |
AddBounceWithCount(String,Integer)
Adds a number of bounce counts on the email address if it exists
Introduced or updated in version: 7
Declaration
Void AddBounceWithCount(String emailAddress, Integer counts)
Parameters
Type | Name | Description |
---|---|---|
String | emailAddress | |
Integer | counts |
Returns
Type | Description |
---|---|
Void |
AddEmailAddressToPerson(Integer,String,Bool)
Sets the primary email address on person, possibly re-ranking email addresses accordingly.
Introduced or updated in version: 8.2
Declaration
Void AddEmailAddressToPerson(Integer personId, String emailAddress, Bool setAsPrimaryEmail)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | |
String | emailAddress | |
Bool | setAsPrimaryEmail |
Returns
Type | Description |
---|---|
Void |
ChangeCountry(NSPersonEntity,Integer)
Changes country and regenerates the default values and localized information such as phone number and address format for this entity.
Introduced or updated in version: 7
Declaration
NSPersonEntity ChangeCountry(NSPersonEntity personEntity, Integer toCountryId)
Parameters
Type | Name | Description |
---|---|---|
NSPersonEntity | personEntity | |
Integer | toCountryId |
Returns
Type | Description |
---|---|
NSPersonEntity |
Examples
NSPersonAgent agent;
NSPersonEntity personEntity;
Integer toCountryId;
NSPersonEntity res = agent.ChangeCountry(personEntity, toCountryId);
ChangePersonRank(Integer,Bool)
Moves one person up or down in the ranking in the Person Archive, if possible. Corresponds to the move up/move down functions in the person archive in the contact panel.
Introduced or updated in version: 7
Declaration
Integer ChangePersonRank(Integer personId, Bool moveUp)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | |
Bool | moveUp |
Returns
Type | Description |
---|---|
Integer |
Remarks
The person record that has rank = 1 is the primary contact for a company, and is the one used in situations where no person has been explicitly chosen (such as in selections).
This method always affects two records.
Examples
NSPersonAgent agent;
Integer personId;
Bool moveUp;
Integer res = agent.ChangePersonRank(personId, moveUp);
CheckTemporaryKey(String)
Checks a temporary key for validity, and in case it is valid, return its domain, targetId and personId
Introduced or updated in version: 8.2
Declaration
NSTemporaryKeyInfo CheckTemporaryKey(String temporaryKey)
Parameters
Type | Name | Description |
---|---|---|
String | temporaryKey |
Returns
Type | Description |
---|---|
NSTemporaryKeyInfo |
Examples
NSPersonAgent agent;
String temporaryKey;
NSTemporaryKeyInfo res = agent.CheckTemporaryKey(temporaryKey);
CreateDefaultByContactId(Integer)
Creates an NSPersonEntity with default values based on the contactId.
Introduced or updated in version: 7
Declaration
NSPersonEntity CreateDefaultByContactId(Integer contactId)
Parameters
Type | Name | Description |
---|---|---|
Integer | contactId |
Returns
Type | Description |
---|---|
NSPersonEntity |
CreateDefaultConsentPerson()
Sets default values into a new NSConsentPerson.
Introduced or updated in version: 8.2
Declaration
NSConsentPerson CreateDefaultConsentPerson()
Returns
Type | Description |
---|---|
NSConsentPerson | A new NSConsentPerson with default values. |
Remarks
NetServer calculates default values (for example, Country) on the entity, which is required when creating/storing a new instance
Examples
NSPersonAgent agent;
NSConsentPerson thing = agent.CreateDefaultConsentPerson();
thing = agent.SaveConsentPerson(thing);
CreateDefaultFromCredential(Integer,String,String,String)
Creates an NSPersonEntity with default values based on the contactId and credentials.
Introduced or updated in version: 7
Declaration
NSPersonEntity CreateDefaultFromCredential(Integer contactId, String credentialType, String credentialValue, String credentialDisplayValue)
Parameters
Type | Name | Description |
---|---|---|
Integer | contactId | |
String | credentialType | |
String | credentialValue | |
String | credentialDisplayValue |
Returns
Type | Description |
---|---|
NSPersonEntity |
CreateDefaultPersonEntity()
Sets default values into a new NSPersonEntity.
Introduced or updated in version: 7
Declaration
NSPersonEntity CreateDefaultPersonEntity()
Returns
Type | Description |
---|---|
NSPersonEntity | A new NSPersonEntity with default values. |
Remarks
NetServer calculates default values (for example, Country) on the entity, which is required when creating/storing a new instance
Examples
NSPersonAgent agent;
NSPersonEntity thing = agent.CreateDefaultPersonEntity();
thing = agent.SavePersonEntity(thing);
CreateTemporaryKey(Integer,Integer,Integer)
Creates a temporary key in the database from the given parameters and return the key string. Used for temporary keys for accessing customer centric functionality, such as UpdateSubscriptions.
Introduced or updated in version: 7
Declaration
String CreateTemporaryKey(Integer domain, Integer targetId, Integer personId, DateTime expires)
Parameters
Type | Name | Description |
---|---|---|
Integer | domain | See TemporaryKeyDomain. |
Integer | targetId | |
Integer | personId | |
expires |
Returns
Type | Description |
---|---|
String |
Examples
NSPersonAgent agent;
Integer domain;
Integer targetId;
Integer personId;
DateTime expires;
String res = agent.CreateTemporaryKey(domain, targetId, personId, expires);
DeleteConsentPerson(Integer)
Deletes the NSConsentPerson
Introduced or updated in version: 8.2
Declaration
DeleteConsentPerson(Integer consentPerson)
Parameters
Type | Name | Description |
---|---|---|
Integer | consentPerson |
Returns
Type | Description |
---|---|
Void |
Examples
NSPersonAgent agent;
agent.DeleteConsentPerson(123);
DeleteExpired()
Trigger deletion of persons that has been (soft) deleted and have timed out the expiry period (the SoftDeleteRetention preference).
Introduced or updated in version: 8.5R08
Declaration
Void DeleteExpired()
Returns
Type | Description |
---|---|
Void |
DeletePersonEntity(Integer)
Deletes the NSPersonEntity
Introduced or updated in version: 7
Declaration
DeletePersonEntity(Integer personEntity)
Parameters
Type | Name | Description |
---|---|---|
Integer | personEntity |
Returns
Type | Description |
---|---|
Void |
Examples
NSPersonAgent agent;
agent.DeletePersonEntity(123);
DeleteTemporaryKeysOfDomain(Integer,Integer)
Deletes all temporary keys for a given domain and person
Introduced or updated in version: 7
Declaration
Void DeleteTemporaryKeysOfDomain(Integer domain, Integer personId)
Parameters
Type | Name | Description |
---|---|---|
Integer | domain | See TemporaryKeyDomain. |
Integer | personId |
Returns
Type | Description |
---|---|
Void |
GetAddress(Integer)
Gets the person's localized addressGets the person's localized address.
Introduced or updated in version: 7
Declaration
NSLocalizedField[][] GetAddress(Integer personId)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | The person Id. |
Returns
Type | Description |
---|---|
The address. |
Examples
NSPersonAgent agent;
Integer personId;
NSAddress res = agent.GetAddress(personId);
GetAddressByCountry(Integer,Integer)
Gets the person's localized addressGets the person's localized address.
Introduced or updated in version: 7
Declaration
NSLocalizedField[][]GetAddressByCountry(Integer personId, Integer countryId)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | The person ID |
Integer | countryId | The country Id. |
Returns
Type | Description |
---|---|
The address. |
Examples
NSPersonAgent agent;
Integer personId;
Integer countryId;
NSAddress res = agent.GetAddressByCountry(personId, countryId);
GetBestSoLanguageForTemplate(Integer,Integer)
Gets the best language for this person on this template
Introduced or updated in version: 7
Declaration
String GetBestSoLanguageForTemplate(Integer personId, Integer templateId)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | |
Integer | templateId |
Returns
Type | Description |
---|---|
String |
Examples
NSPersonAgent agent;
Integer personId;
Integer templateId;
String res = agent.GetBestSoLanguageForTemplate(personId, templateId);
GetColleagues()
Gets the persons working in the same company as the logged-on user.
Introduced or updated in version: 7
Declaration
NSPerson[] GetColleagues()
Returns
Type | Description |
---|---|
NSPerson[] |
Examples
NSPersonAgent agent;
NSPerson[] res = agent.GetColleagues();
GetColleaguesByDepartment(Integer)
Gets the persons working in a specific department in the same company as the logged-on user
Introduced or updated in version: 7
Declaration
NSPerson[] GetColleaguesByDepartment(Integer departmentId)
Parameters
Type | Name | Description |
---|---|---|
Integer | departmentId |
Returns
Type | Description |
---|---|
NSPerson[] |
Remarks
Departments can be retrieved with the PhoneList.DepartmentList service.
Examples
NSPersonAgent agent;
Integer departmentId;
NSPerson[] res = agent.GetColleaguesByDepartment(departmentId);
GetColleaguesBySource(Integer,Integer)
Gets the persons working in the same company as the logged-on user.
Introduced or updated in version: 7
Declaration
NSPerson[] GetColleaguesBySource(Integer sourceType, Integer count)
Parameters
Type | Name | Description |
---|---|---|
Integer | sourceType | See ContactSourceType. |
Integer | count |
Returns
Type | Description |
---|---|
NSPerson[] |
Remarks
The list of persons could be retrieved from the history list, the diary view list, or from all sources.
Examples
NSPersonAgent agent;
Integer sourceType;
Integer count;
NSPerson[] res = agent.GetColleaguesBySource(sourceType, count);
GetConsentInfos(Integer)
Gets all consent information for a given person. May include withdrawn consents (check)
Introduced or updated in version: 8.2
Declaration
NSConsentInfo[] GetConsentInfos(Integer personId)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId |
Returns
Type | Description |
---|---|
NSConsentInfo[] |
Examples
NSPersonAgent agent;
Integer personId;
NSConsentInfo[] res = agent.GetConsentInfos(personId);
GetConsentPerson(Integer)
Gets an NSConsentPerson object.
Introduced or updated in version: 8.2
Declaration
NSConsentPerson GetConsentPerson(Integer consentPersonId)
Parameters
Type | Name | Description |
---|---|---|
Integer | consentPersonId |
Returns
Type | Description |
---|---|
NSConsentPerson |
Examples
NSPersonAgent agent;
NSConsentPerson thing = agent.GetConsentPerson(123);
GetMyOwner()
Gets the owner of the logged in person.
Introduced or updated in version: 7
Declaration
NSPerson GetMyOwner()
Returns
Type | Description |
---|---|
NSPerson |
Examples
NSPersonAgent agent;
NSPerson res = agent.GetMyOwner();
GetMyPerson()
Gets the person info belonging to the currently logged-on user.
Introduced or updated in version: 7
Declaration
NSPersonEntity GetMyPerson()
Returns
Type | Description |
---|---|
NSPersonEntity |
Examples
NSPersonAgent agent;
NSPersonEntity res = agent.GetMyPerson();
GetOwnerOnPersonId(Integer)
Gets the owner of the person by ID.
Introduced or updated in version: 7
Declaration
NSPerson GetOwnerOnPersonId(Integer personId)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId |
Returns
Type | Description |
---|---|
NSPerson |
Examples
NSPersonAgent agent;
Integer personId;
NSPerson res = agent.GetOwnerOnPersonId(personId);
GetPerson(Integer)
Gets an NSPerson object.
Introduced or updated in version: 7
Declaration
NSPerson GetPerson(Integer personId)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId |
Returns
Type | Description |
---|---|
NSPerson |
Examples
NSPersonAgent agent;
NSPerson thing = agent.GetPerson(123);
GetPersonEntity(Integer)
Gets an NSPersonEntity object.
Introduced or updated in version: 7
Declaration
NSPersonEntity GetPersonEntity(Integer personEntityId)
Parameters
Type | Name | Description |
---|---|---|
Integer | personEntityId |
Returns
Type | Description |
---|---|
NSPersonEntity |
Examples
NSPersonAgent agent;
NSPersonEntity thing = agent.GetPersonEntity(123);
GetPersonImage(Integer)
Returns the person image that is displayed in the CRM application.
Introduced or updated in version: 7
Declaration
NSImage GetPersonImage(Integer personId)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId |
Returns
Type | Description |
---|---|
NSImage |
Examples
NSPersonAgent agent;
Integer personId;
NSImage res = agent.GetPersonImage(personId);
GetPersonList(Integer[])
Gets an array of NSPerson objects.
Introduced or updated in version: 7
Declaration
NSPerson[] GetPersonList(Integer[] personIds)
Parameters
Type | Name | Description |
---|---|---|
Integer[] | personIds |
Returns
Type | Description |
---|---|
NSPerson[] |
Examples
Integer[] ids;
NSPersonAgent agent;
agent.GetPersonList(ids);
GetPersonsFromContact(Integer)
Returns all the persons belonging to a contact.
Introduced or updated in version: 7
Declaration
NSPerson[] GetPersonsFromContact(Integer contactId)
Parameters
Type | Name | Description |
---|---|---|
Integer | contactId |
Returns
Type | Description |
---|---|
NSPerson[] |
Examples
NSPersonAgent agent;
Integer contactId;
NSPerson[] res = agent.GetPersonsFromContact(contactId);
GetPersonsFromProject(Integer)
Returns all the persons belonging to a project.
Introduced or updated in version: 7
Declaration
NSPerson[] GetPersonsFromProject(Integer projectId)
Parameters
Type | Name | Description |
---|---|---|
Integer | projectId |
Returns
Type | Description |
---|---|
NSPerson[] |
Examples
NSPersonAgent agent;
Integer projectId;
NSPerson[] res = agent.GetPersonsFromProject(projectId);
GetPersonSummary(Integer,Integer)
Gets summary of person and recent activity.
Introduced or updated in version: 8.5R08
Declaration
NSPersonSummary GetPersonSummary(Integer personId, Integer limit)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | |
Integer | limit |
Returns
Type | Description |
---|---|
NSPersonSummary |
Examples
NSPersonAgent agent;
Integer personId;
Integer limit;
NSPersonSummary res = agent.GetPersonSummary(personId, limit);
GetPhones(Integer)
Returns all phones that belong to a person, ordered by the phone type.
Introduced or updated in version: 7
Declaration
NSEntityElement[] GetPhones(Integer personId)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId |
Returns
Type | Description |
---|---|
NSEntityElement[] |
Examples
NSPersonAgent agent;
Integer personId;
NSEntityElement[] res = agent.GetPhones(personId);
GetSalesRep(String,String,String,String,String)
Returns the sales representative for an external user.
Introduced or updated in version: 7
Declaration
NSPersonEntity GetSalesRep(String contactName, String personFirstname, String personLastname, String emailAddress, String phoneNumber)
Parameters
Type | Name | Description |
---|---|---|
String | contactName | |
String | personFirstname | |
String | personLastname | |
String | emailAddress | |
String | phoneNumber |
Returns
Type | Description |
---|---|
NSPersonEntity |
Remarks
If this method is accessed with anonymous authentication the external user is recognized by contact and name, or by email, or phone number.
If the external user is recognized as an CRM5 user (internal or external) the input fields can be left blank.
Examples
NSPersonAgent agent;
String contactName;
String personFirstname;
String personLastname;
String emailAddress;
String phoneNumber;
NSPersonEntity res = agent.GetSalesRep(contactName, personFirstname, personLastname, emailAddress, phoneNumber);
HasConsent(Integer,String)
Checks if consent has been given by a specified person, for a specific purpose. Withdraw consents return FALSE.
Introduced or updated in version: 8.2
Declaration
Bool HasConsent(Integer personId, String purpose)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | |
String | purpose |
Returns
Type | Description |
---|---|
Bool |
Examples
NSPersonAgent agent;
Integer personId;
String purpose;
Bool res = agent.HasConsent(personId, purpose);
IsNumberValid(Integer,String)
Checks if the number is unique or required.
Introduced or updated in version: 7
Declaration
Bool IsNumberValid(Integer contactId, String number)
Parameters
Type | Name | Description |
---|---|---|
Integer | contactId | |
String | number |
Returns
Type | Description |
---|---|
Bool |
Remarks
The setting is configured from admin under system options.
Examples
NSPersonAgent agent;
Integer contactId;
String number;
Bool res = agent.IsNumberValid(contactId, number);
Merge(Integer,Integer,DateTime,Bool,Bool)
Merges two persons. The destination person will remain. You must specify the date after which activities will be moved along with the person.
Introduced or updated in version: 7
Declaration
Void Merge(Integer sourcePersonId, Integer destinationPersonId, DateTime moveAfterDate, Bool deleteSource, Bool replaceEmptyFieldsOnDestination)
Parameters
Type | Name | Description |
---|---|---|
Integer | sourcePersonId | |
Integer | destinationPersonId | |
moveAfterDate | ||
Bool | deleteSource | |
Bool | replaceEmptyFieldsOnDestination |
Returns
Type | Description |
---|---|
Void |
Move(Integer,Integer,DateTime)
Moves a person to a specified contact. You must specify the date after which activities will be moved along with the person.
Introduced or updated in version: 7
Declaration
Void Move(Integer personId, Integer destinationContactId, DateTime moveAfterDate)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | |
Integer | destinationContactId | |
moveAfterDate |
Returns
Type | Description |
---|---|
Void |
NormalizeRanks(Integer)
Normalize the ranks for all persons that belong to a contact. This means that the persons will be sorted according to their current rank values, and the ranks will be made monotonically increasing from 1.
Introduced or updated in version: 7
Declaration
Bool NormalizeRanks(Integer contactId)
Parameters
Type | Name | Description |
---|---|---|
Integer | contactId |
Returns
Type | Description |
---|---|
Bool |
Examples
NSPersonAgent agent;
Integer contactId;
Bool res = agent.NormalizeRanks(contactId);
RemoveConsent(Integer,String)
Turns off consent for a specified person and purpose.
Introduced or updated in version: 8.2
Declaration
Void RemoveConsent(Integer personId, String purpose)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | |
String | purpose |
Returns
Type | Description |
---|---|
Void |
ResolvePersonFromInfo(Integer,String,String[],String[])
Gets a person from the provided information. If the person does not exist, it will be created on demand.
Introduced or updated in version: 7.5
Declaration
NSResolvedPerson ResolvePersonFromInfo(Integer contactId, String personName, String[] phoneNumbers, String[] emails)
Parameters
Type | Name | Description |
---|---|---|
Integer | contactId | |
String | personName | |
String[] | phoneNumbers | |
String[] | emails |
Returns
Type | Description |
---|---|
NSResolvedPerson |
Examples
NSPersonAgent agent;
Integer contactId;
String personName;
String[] phoneNumbers;
String[] emails;
NSResolvedPerson res = agent.ResolvePersonFromInfo(contactId, personName, phoneNumbers, emails);
SaveConsentPerson(NSConsentPerson)
Updates the existing NSConsentPerson or creates a new NSConsentPerson if the id parameter is 0
Introduced or updated in version: 8.2
Declaration
NSConsentPerson SaveConsentPerson(NSConsentPerson consentPerson)
Parameters
Type | Name | Description |
---|---|---|
NSConsentPerson | consentPerson | The NSConsentPerson to save. |
Returns
Type | Description |
---|---|
NSConsentPerson |
Examples
NSPerson agent;
NSConsentPerson thing = agent.CreateDefaultConsentPerson();
thing = agent.SaveConsentPerson(thing);
SavePersonEntity(NSPersonEntity)
Creates or updates an NSPersonEntityUpdates the existing NSPersonEntity or creates a new NSPersonEntity if the ID parameter is 0.
Introduced or updated in version: 7
Declaration
NSPersonEntity SavePersonEntity()
Parameters
Type | Name | Description |
---|---|---|
NSPersonEntity | personEntity | The entity to save. |
Returns
Type | Description |
---|---|
NSPersonEntity |
Examples
NSPerson agent;
NSPersonEntity thing = agent.CreateDefaultPersonEntity();
thing = agent.SavePersonEntity(thing);
SendConsentConfirmationEmail(Integer,String,Integer,Integer,String)
Sends a confirmation email to the provided person, email address (id), using the document template
Introduced or updated in version: 8.2
Declaration
Void SendConsentConfirmationEmail(Integer personId, String emailAddress, Integer emailTemplateId, Integer cultureLcidId, String subject)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | |
String | emailAddress | |
Integer | emailTemplateId | |
Integer | cultureLcidId | |
String | subject |
Returns
Type | Description |
---|---|
Void |
SetConsent(Integer,String,String,String,String)
Sets a specified type of consent on the person.
Introduced or updated in version: 8.2
Declaration
Void SetConsent(Integer personId, String purpose, String source, String legalBase, String comment)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | |
String | purpose | |
String | source | |
String | legalBase | |
String | comment |
Returns
Type | Description |
---|---|
Void |
SetPersonImage(Integer)
Stores the person image that is displayed in the CRM application.
Introduced or updated in version: 7
Declaration
Void SetPersonImage(Integer personId, NSImage image)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId |
Returns
Type | Description |
---|---|
Void |
SetPersonRank(Integer,Integer)
Directly sets the rank field of a person record, adjusting all other person records under the same contact as needed.
Introduced or updated in version: 7
Declaration
Bool SetPersonRank(Integer personId, Integer desiredRank)
Parameters
Type | Name | Description |
---|---|---|
Integer | personId | |
Integer | desiredRank |
Returns
Type | Description |
---|---|
Bool |
Remarks
May affect multiple records, potentially all person records belonging to one contact.
You must have write access for to affected records for this method to succeed.
Examples
NSPersonAgent agent;
Integer personId;
Integer desiredRank;
Bool res = agent.SetPersonRank(personId, desiredRank);
Undelete(Integer)
This entity supports Soft Delete. Call this method to Undelete a previously soft-deleted record
Introduced or updated in version: 8.2
Declaration
Void Undelete(Integer id)
Parameters
Type | Name | Description |
---|---|---|
Integer | id |
Returns
Type | Description |
---|---|
Void |
Examples
NSPersonAgent agent;
Integer id;
agent.Undelete(id);
ValidatePersonEntity(NSPersonEntity)
Checks that entity is ready for saving, return error messages by field.
Introduced or updated in version: 7
Declaration
Map ValidatePersonEntity(NSPersonEntity personEntity)
Parameters
Type | Name | Description |
---|---|---|
NSPersonEntity | personEntity |
Returns
Type | Description |
---|---|
Map |
Examples
NSPersonAgent agent;
NSPersonEntity personEntity;
Map res = agent.ValidatePersonEntity(personEntity);