Class NSPersonAgent

Person data services.

Examples

NSPersonAgent agent;
agent.callMethod(arg1, arg2);

Constructors

NSPersonAgent()

Person data services.

Declaration

NSPersonAgent

Examples

NSPersonAgent agent;
agent.callMethod(arg1, arg2);

Methods

AddBounce(String)

Adds a bounce count on the email address if it exists

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

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.

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.

Declaration

NSPersonEntity ChangeCountry(NSPersonEntity personEntity, Integer toCountryId)

Examples

NSPersonAgent agent;
NSPersonEntity personEntity;
Integer toCountryId;
NSPersonEntity res = agent.ChangeCountry(personEntity, toCountryId);

Parameters

Type Name Description
NSPersonEntity personEntity
Integer toCountryId

Returns

Type Description
NSPersonEntity

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.

Declaration

Integer ChangePersonRank(Integer personId, Bool moveUp)

Examples

NSPersonAgent agent;
Integer personId;
Bool moveUp;
Integer res = agent.ChangePersonRank(personId, moveUp);

Parameters

Type Name Description
Integer personId
Bool moveUp

Returns

Type Description
Integer

CheckTemporaryKey(String)

Checks a temporary key for validity, and in case it is valid, return its domain, targetId and personId

Declaration

NSTemporaryKeyInfo CheckTemporaryKey(String temporaryKey)

Examples

NSPersonAgent agent;
String temporaryKey;
NSTemporaryKeyInfo res = agent.CheckTemporaryKey(temporaryKey);

Parameters

Type Name Description
String temporaryKey

Returns

Type Description
NSTemporaryKeyInfo

CreateDefaultByContactId(Integer)

Creates an NSPersonEntity with default values based on the contactId.

Declaration

NSPersonEntity CreateDefaultByContactId(Integer contactId)

Parameters

Type Name Description
Integer contactId

Returns

Type Description
NSPersonEntity

CreateDefaultConsentPerson()

Sets default values into a new NSConsentPerson.

Declaration

NSConsentPerson CreateDefaultConsentPerson()

Examples

NSPersonAgent agent;
NSConsentPerson thing = agent.CreateDefaultConsentPerson();
thing = agent.SaveConsentPerson(thing);

Returns

Type Description
NSConsentPerson A new NSConsentPerson with default values.

CreateDefaultFromCredential(Integer,String,String,String)

Creates an NSPersonEntity with default values based on the contactId and credentials.

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.

Declaration

NSPersonEntity CreateDefaultPersonEntity()

Examples

NSPersonAgent agent;
NSPersonEntity thing = agent.CreateDefaultPersonEntity();
thing = agent.SavePersonEntity(thing);

Returns

Type Description
NSPersonEntity A new NSPersonEntity with default values.

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.

Declaration

String CreateTemporaryKey(Integer domain, Integer targetId, Integer personId, DateTime expires)

Examples

NSPersonAgent agent;
Integer domain;
Integer targetId;
Integer personId;
DateTime expires;
String res = agent.CreateTemporaryKey(domain, targetId, personId, expires);

Parameters

Type Name Description
Integer domain See <xref href="CRMScript.NetServer.TemporaryKeyDomain" data-throw-if-not-resolved="false"></xref>.
Integer targetId
Integer personId
expires

Returns

Type Description
String

DeleteConsentPerson(Integer)

Deletes the NSConsentPerson

Declaration

DeleteConsentPerson(Integer consentPerson)

Examples

NSPersonAgent agent;
agent.DeleteConsentPerson(123);

Parameters

Type Name Description
Integer consentPerson

Returns

Type Description
Void

DeleteExpired()

Trigger deletion of persons that has been (soft) deleted and have timed out the expiry period (the SoftDeleteRetention preference).

Declaration

Void DeleteExpired()

Returns

Type Description
Void

DeletePersonEntity(Integer)

Deletes the NSPersonEntity

Declaration

DeletePersonEntity(Integer personEntity)

Examples

NSPersonAgent agent;
agent.DeletePersonEntity(123);

Parameters

Type Name Description
Integer personEntity

Returns

Type Description
Void

DeleteTemporaryKeysOfDomain(Integer,Integer)

Deletes all temporary keys for a given domain and person

Declaration

Void DeleteTemporaryKeysOfDomain(Integer domain, Integer personId)

Parameters

Type Name Description
Integer domain See <xref href="CRMScript.NetServer.TemporaryKeyDomain" data-throw-if-not-resolved="false"></xref>.
Integer personId

Returns

Type Description
Void

GetAddress(Integer)

Gets the person's localized addressGets the person's localized address.

Declaration

NSLocalizedField[][] GetAddress(Integer personId)

Examples

NSPersonAgent agent;
Integer personId;
NSAddress res = agent.GetAddress(personId);

Parameters

Type Name Description
Integer personId The person Id.

Returns

Type Description
The address.

GetAddressByCountry(Integer,Integer)

Gets the person's localized addressGets the person's localized address.

Declaration

NSLocalizedField[][]GetAddressByCountry(Integer personId, Integer countryId)

Examples

NSPersonAgent agent;
Integer personId;
Integer countryId;
NSAddress res = agent.GetAddressByCountry(personId, countryId);

Parameters

Type Name Description
Integer personId The person ID
Integer countryId The country Id.

Returns

Type Description
The address.

GetBestSoLanguageForTemplate(Integer,Integer)

Gets the best language for this person on this template

Declaration

String GetBestSoLanguageForTemplate(Integer personId, Integer templateId)

Examples

NSPersonAgent agent;
Integer personId;
Integer templateId;
String res = agent.GetBestSoLanguageForTemplate(personId, templateId);

Parameters

Type Name Description
Integer personId
Integer templateId

Returns

Type Description
String

GetColleagues()

Gets the persons working in the same company as the logged-on user.

Declaration

NSPerson[] GetColleagues()

Examples

NSPersonAgent agent;
NSPerson[] res = agent.GetColleagues();

Returns

Type Description
NSPerson[]

GetColleaguesByDepartment(Integer)

Gets the persons working in a specific department in the same company as the logged-on user

Declaration

NSPerson[] GetColleaguesByDepartment(Integer departmentId)

Examples

NSPersonAgent agent;
Integer departmentId;
NSPerson[] res = agent.GetColleaguesByDepartment(departmentId);

Parameters

Type Name Description
Integer departmentId

Returns

Type Description
NSPerson[]

GetColleaguesBySource(Integer,Integer)

Gets the persons working in the same company as the logged-on user.

Declaration

NSPerson[] GetColleaguesBySource(Integer sourceType, Integer count)

Examples

NSPersonAgent agent;
Integer sourceType;
Integer count;
NSPerson[] res = agent.GetColleaguesBySource(sourceType, count);

Parameters

Type Name Description
Integer sourceType See <xref href="CRMScript.NetServer.ContactSourceType" data-throw-if-not-resolved="false"></xref>.
Integer count

Returns

Type Description
NSPerson[]

GetConsentInfos(Integer)

Gets all consent information for a given person. May include withdrawn consents (check)

Declaration

NSConsentInfo[] GetConsentInfos(Integer personId)

Examples

NSPersonAgent agent;
Integer personId;
NSConsentInfo[] res = agent.GetConsentInfos(personId);

Parameters

Type Name Description
Integer personId

Returns

Type Description
NSConsentInfo[]

GetConsentPerson(Integer)

Gets an NSConsentPerson object.

Declaration

NSConsentPerson GetConsentPerson(Integer consentPersonId)

Examples

NSPersonAgent agent;
NSConsentPerson thing = agent.GetConsentPerson(123);

Parameters

Type Name Description
Integer consentPersonId

Returns

Type Description
NSConsentPerson

GetMyOwner()

Gets the owner of the logged in person.

Declaration

NSPerson GetMyOwner()

Examples

NSPersonAgent agent;
NSPerson res = agent.GetMyOwner();

Returns

Type Description
NSPerson

GetMyPerson()

Gets the person info belonging to the currently logged-on user.

Declaration

NSPersonEntity GetMyPerson()

Examples

NSPersonAgent agent;
NSPersonEntity res = agent.GetMyPerson();

Returns

Type Description
NSPersonEntity

GetOwnerOnPersonId(Integer)

Gets the owner of the person by ID.

Declaration

NSPerson GetOwnerOnPersonId(Integer personId)

Examples

NSPersonAgent agent;
Integer personId;
NSPerson res = agent.GetOwnerOnPersonId(personId);

Parameters

Type Name Description
Integer personId

Returns

Type Description
NSPerson

GetPerson(Integer)

Gets an NSPerson object.

Declaration

NSPerson GetPerson(Integer personId)

Examples

NSPersonAgent agent;
NSPerson thing = agent.GetPerson(123);

Parameters

Type Name Description
Integer personId

Returns

Type Description
NSPerson

GetPersonEntity(Integer)

Gets an NSPersonEntity object.

Declaration

NSPersonEntity GetPersonEntity(Integer personEntityId)

Examples

NSPersonAgent agent;
NSPersonEntity thing = agent.GetPersonEntity(123);

Parameters

Type Name Description
Integer personEntityId

Returns

Type Description
NSPersonEntity

GetPersonImage(Integer)

Returns the person image that is displayed in the CRM application.

Declaration

NSImage GetPersonImage(Integer personId)

Examples

NSPersonAgent agent;
Integer personId;
NSImage res = agent.GetPersonImage(personId);

Parameters

Type Name Description
Integer personId

Returns

Type Description
NSImage

GetPersonList(Integer[])

Gets an array of NSPerson objects.

Declaration

NSPerson[] GetPersonList(Integer[]  personIds)

Examples

Integer[] ids;
NSPersonAgent agent;
agent.GetPersonList(ids);

Parameters

Type Name Description
Integer[] personIds

Returns

Type Description
NSPerson[]

GetPersonsFromContact(Integer)

Returns all the persons belonging to a contact.

Declaration

NSPerson[] GetPersonsFromContact(Integer contactId)

Examples

NSPersonAgent agent;
Integer contactId;
NSPerson[] res = agent.GetPersonsFromContact(contactId);

Parameters

Type Name Description
Integer contactId

Returns

Type Description
NSPerson[]

GetPersonsFromProject(Integer)

Returns all the persons belonging to a project.

Declaration

NSPerson[] GetPersonsFromProject(Integer projectId)

Examples

NSPersonAgent agent;
Integer projectId;
NSPerson[] res = agent.GetPersonsFromProject(projectId);

Parameters

Type Name Description
Integer projectId

Returns

Type Description
NSPerson[]

GetPersonSummary(Integer,Integer)

Gets summary of person and recent activity.

Declaration

NSPersonSummary GetPersonSummary(Integer personId, Integer limit)

Examples

NSPersonAgent agent;
Integer personId;
Integer limit;
NSPersonSummary res = agent.GetPersonSummary(personId, limit);

Parameters

Type Name Description
Integer personId
Integer limit

Returns

Type Description
NSPersonSummary

GetPhones(Integer)

Returns all phones that belong to a person, ordered by the phone type.

Declaration

NSEntityElement[] GetPhones(Integer personId)

Examples

NSPersonAgent agent;
Integer personId;
NSEntityElement[] res = agent.GetPhones(personId);

Parameters

Type Name Description
Integer personId

Returns

Type Description
NSEntityElement[]

GetSalesRep(String,String,String,String,String)

Returns the sales representative for an external user.

Declaration

NSPersonEntity GetSalesRep(String contactName, String personFirstname, String personLastname, String emailAddress, String phoneNumber)

Examples

NSPersonAgent agent;
String contactName;
String personFirstname;
String personLastname;
String emailAddress;
String phoneNumber;
NSPersonEntity res = agent.GetSalesRep(contactName, personFirstname, personLastname, emailAddress, phoneNumber);

Parameters

Type Name Description
String contactName
String personFirstname
String personLastname
String emailAddress
String phoneNumber

Returns

Type Description
NSPersonEntity

HasConsent(Integer,String)

Checks if consent has been given by a specified person, for a specific purpose. Withdraw consents return FALSE.

Declaration

Bool HasConsent(Integer personId, String purpose)

Examples

NSPersonAgent agent;
Integer personId;
String purpose;
Bool res = agent.HasConsent(personId, purpose);

Parameters

Type Name Description
Integer personId
String purpose

Returns

Type Description
Bool

IsNumberValid(Integer,String)

Checks if the number is unique or required.

Declaration

Bool IsNumberValid(Integer contactId, String number)

Examples

NSPersonAgent agent;
Integer contactId;
String number;
Bool res = agent.IsNumberValid(contactId, number);

Parameters

Type Name Description
Integer contactId
String number

Returns

Type Description
Bool

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.

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.

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.

Declaration

Bool NormalizeRanks(Integer contactId)

Examples

NSPersonAgent agent;
Integer contactId;
Bool res = agent.NormalizeRanks(contactId);

Parameters

Type Name Description
Integer contactId

Returns

Type Description
Bool

RemoveConsent(Integer,String)

Turns off consent for a specified person and purpose.

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.

Declaration

NSResolvedPerson ResolvePersonFromInfo(Integer contactId, String personName, String[] phoneNumbers, String[] emails)

Examples

NSPersonAgent agent;
Integer contactId;
String personName;
String[] phoneNumbers;
String[] emails;
NSResolvedPerson res = agent.ResolvePersonFromInfo(contactId, personName, phoneNumbers, emails);

Parameters

Type Name Description
Integer contactId
String personName
String[] phoneNumbers
String[] emails

Returns

Type Description
NSResolvedPerson

SaveConsentPerson(NSConsentPerson)

Updates the existing NSConsentPerson or creates a new NSConsentPerson if the id parameter is 0

Declaration

NSConsentPerson SaveConsentPerson(NSConsentPerson consentPerson)

Examples

NSPerson  agent;
NSConsentPerson thing = agent.CreateDefaultConsentPerson();
thing = agent.SaveConsentPerson(thing);

Parameters

Type Name Description
NSConsentPerson consentPerson The NSConsentPerson to save.

Returns

Type Description
NSConsentPerson

SavePersonEntity(NSPersonEntity)

Creates or updates an NSPersonEntityUpdates the existing NSPersonEntity or creates a new NSPersonEntity if the ID parameter is 0.

Declaration

NSPersonEntity SavePersonEntity()

Examples

NSPerson  agent;
NSPersonEntity thing = agent.CreateDefaultPersonEntity();
thing = agent.SavePersonEntity(thing);

Parameters

Type Name Description
NSPersonEntity personEntity The entity to save.

Returns

Type Description
NSPersonEntity

SendConsentConfirmationEmail(Integer,String,Integer,Integer,String)

Sends a confirmation email to the provided person, email address (id), using the document template

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.

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.

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.

Declaration

Bool SetPersonRank(Integer personId, Integer desiredRank)

Examples

NSPersonAgent agent;
Integer personId;
Integer desiredRank;
Bool res = agent.SetPersonRank(personId, desiredRank);

Parameters

Type Name Description
Integer personId
Integer desiredRank

Returns

Type Description
Bool

TryAddPersonsToEmailFlow(Integer,Integer[])

Attempts to add multiple persons to an email flow, returning an array of boolean values indicating success for each person.

Declaration

Bool[] TryAddPersonsToEmailFlow(Integer flowId, Integer[] personIds)

Examples

NSPersonAgent agent;
Integer[] personIds;
personIds.pushBack(2);
agent.TryAddPersonsToEmailFlow(1, personIds);

Parameters

Type Name Description
Integer flowId The ID of the email flow to which persons will be added.
Integer[] personIds An array of person IDs to be added to the email flow.

Returns

Type Description
Bool[] An array of boolean values indicating whether each person was successfully added to the email flow.

Undelete(Integer)

This entity supports Soft Delete. Call this method to Undelete a previously soft-deleted record

Declaration

Void Undelete(Integer id)

Examples

NSPersonAgent agent;
Integer id;
agent.Undelete(id);

Parameters

Type Name Description
Integer id

Returns

Type Description
Void

ValidatePersonEntity(NSPersonEntity)

Checks that entity is ready for saving, return error messages by field.

Declaration

Map ValidatePersonEntity(NSPersonEntity personEntity)

Examples

NSPersonAgent agent;
NSPersonEntity personEntity;
Map res = agent.ValidatePersonEntity(personEntity);

Parameters

Type Name Description
NSPersonEntity personEntity

Returns

Type Description
Map