Class NSContactAgent

Contact (company) data services.

Examples

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

Constructors

NSContactAgent()

Initializes a new instance of the NSContactAgent class.

Declaration

NSContactAgent

Examples

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

Methods

AddPerson(Integer,NSPersonEntity)

Adds a person to the given contact

Declaration

NSPersonEntity AddPerson(Integer contactId, NSPersonEntity newPersonEntity)

Examples

NSContactAgent agent;
Integer contactId;
NSPersonEntity newPersonEntity;
NSPersonEntity res = agent.AddPerson(contactId, newPersonEntity);

Parameters

Type Name Description
Integer contactId Contact to add person to
NSPersonEntity newPersonEntity Person object to add.

Returns

Type Description
NSPersonEntity Updated person object.

ChangeCountry(NSContactEntity,Integer)

Changes country regenerates the default values and localized information such as phone number and address format

Declaration

NSContactEntity ChangeCountry(NSContactEntity contactEntity, Integer toCountryId)

Parameters

Type Name Description
NSContactEntity contactEntity
Integer toCountryId The country to switch to.

Returns

Type Description
NSContactEntity

Copy(Integer,String,String,Bool)

Copies a contact. Activities and related data will be ignored

Declaration

Integer Copy(Integer sourceContactId, String destinationContactName, String destinationContactDepartment, Bool copyPersons)

Examples

NSContactAgent agent;
Integer sourceContactId;
String destinationContactName;
String destinationContactDepartment;
Bool copyPersons;
Integer res = agent.Copy(sourceContactId, destinationContactName, destinationContactDepartment, copyPersons);

Parameters

Type Name Description
Integer sourceContactId The ID of the contact to copy
String destinationContactName The name of the destination contact
String destinationContactDepartment The department of the destination contact
Bool copyPersons If true, persons will be copied from source contact.

Returns

Type Description
Integer ID of copied contact.

CreateDefaultContactEntity()

Sets default values into a new NSContactEntity.

Declaration

NSContactEntity CreateDefaultContactEntity()

Examples

NSContactAgent agent;
NSContactEntity thing = agent.CreateDefaultContactEntity();
thing = agent.SaveContactEntity(thing);

Returns

Type Description
NSContactEntity New ContactEntity with default values.

CreateNewEntry(NSDuplicateEntry)

Creates a new contact based on external duplicate

Declaration

Integer CreateNewEntry(NSDuplicateEntry duplicate)

Examples

NSContactAgent agent;
NSDuplicateEntry duplicate;
Integer res = agent.CreateNewEntry(duplicate);

Parameters

Type Name Description
NSDuplicateEntry duplicate The duplicate to create a new entry based upon.

Returns

Type Description
Integer The database identity of the newly created entry.

DeleteContactEntity(Integer)

Deletes the NSContactEntity

Declaration

Void DeleteContactEntity(Integer contactEntity)

Examples

NSContactAgent agent;
agent.DeleteContactEntity(123);

Parameters

Type Name Description
Integer contactEntity The identity of the ContactEntity.

Returns

Type Description
Void

DeleteExpired()

Triggers deletion of contacts (companies) that has been (soft) deleted and have timed out the expiry period (the SoftDeleteRetention preference).

Declaration

Void DeleteExpired()

Returns

Type Description
Void

GetAddress(Integer)

Gets a contact's localized addressGets the contact's localized address

Declaration

LocalizedField[][]GetAddress(Integer contact Id)

Examples

NSContactAgent agent;
Integer contactId;
NSAddress res = agent.GetAddress(contactId);

Parameters

Type Name Description
Integer contactId The contact Id.

Returns

Type Description

GetAddressByCountry(Integer,Integer)

Gets a contact's localized addressGets the contact's localized address

Declaration

LocalizedField[][] GetAddressByCountry(Integer contactId, Integer countryId)

Examples

NSContactAgent agent;
Integer contactId;
Integer countryId;
NSAddress res = agent.GetAddressByCountry(contactId, countryId);

Parameters

Type Name Description
Integer contactId The contact ID
Integer countryId The country Id.

Returns

Type Description

GetContact(Integer)

Gets an NSContact object.

Declaration

NSContact GetContact(Integer contactId)

Examples

NSContactAgent agent;
NSContact thing = agent.GetContact(123);

Parameters

Type Name Description
Integer contactId The identifier of the Contact object.

Returns

Type Description
NSContact

GetContactEntity(Integer)

Gets an NSContactEntity object.

Declaration

NSContactEntity GetContactEntity(Integer contactEntityId)

Examples

NSContactAgent agent;
NSContactEntity thing = agent.GetContactEntity(123);

Parameters

Type Name Description
Integer contactEntityId The identifier of the ContactEntity object.

Returns

Type Description
NSContactEntity

GetContactList(Integer[])

Gets an array of Contact objects.

Declaration

NSContact[] GetContactList(Integer[] contactIds)

Examples

Integer[] ids;
NSContactAgent agent;
agent.GetContactList(ids);

Parameters

Type Name Description
Integer[] contactIds Array of identifiers for Contact.

Returns

Type Description
NSContact[] Array of NSContact.

GetContactSummary(Integer,Integer)

Gets summary of contact and its recent activity.

Declaration

NSContactSummary GetContactSummary(Integer contactId, Integer limit)

Examples

NSContactAgent agent;
Integer contactId;
Integer limit;
NSContactSummary res = agent.GetContactSummary(contactId, limit);

Parameters

Type Name Description
Integer contactId The contact ID to summarize.
Integer limit Max number of items to include in summary lists.

Returns

Type Description
NSContactSummary Summary of contact, with recent requests, sales, follow-ups, chats.

GetContactWithPersons(Integer)

Returns the contact with all the contact persons belonging to the contact

Declaration

NSContactEntity GetContactWithPersons(Integer contactId)

Examples

NSContactAgent agent;
Integer contactId;
NSContactEntity res = agent.GetContactWithPersons(contactId);

Parameters

Type Name Description
Integer contactId The ID of the contact.

Returns

Type Description
NSContactEntity ContactEntity with all data and persons.

GetDuplicateRules()

Retrieves all available duplicate rules for contact

Declaration

NSDuplicateRule[] GetDuplicateRules()

Examples

NSContactAgent agent;
NSDuplicateRule[] res = agent.GetDuplicateRules();

Returns

Type Description
NSDuplicateRule[] All available duplicate rules.

GetDuplicates(String)

Gets duplicates (exact or similar in the database) based on the name

Declaration

NSDuplicateEntry[] GetDuplicates(String name)

Examples

NSContactAgent agent;
String name;
NSDuplicateEntry[] res = agent.GetDuplicates(name);

Parameters

Type Name Description
String name Name used for lookup.

Returns

Type Description
NSDuplicateEntry[] Any records matching the specified name.

GetMyActiveContacts(DateTime,Integer[],Integer)

Returns the contacts where there has been activity since activityStartTime.

Declaration

NSContactActivity[] GetMyActiveContacts(DateTime activityStartTime, Integer[] contactCategories, Integer actionType)

Examples

NSContactAgent agent;
DateTime activityStartTime;
Integer[] contactCategories;
Integer actionType;
NSContactActivity[] res = agent.GetMyActiveContacts(activityStartTime, contactCategories, actionType);

Parameters

Type Name Description
activityStartTime The start time of the activities. If the start time is set to a future date; activities since the user last logged out are returned.
Integer[] contactCategories The type of action that has occurred. For example, updates, deletes, new appointments
Integer actionType See <xref href="CRMScript.NetServer.ContactAction" data-throw-if-not-resolved="false"></xref>.

Returns

Type Description
NSContactActivity[] Array of contacts where there have been activity in the period.

GetMyBizCard()

Returns all data needed to display the logged on person's business card (company, person, and company interest data).

Declaration

NSContactEntity GetMyBizCard()

Examples

NSContactAgent agent;
NSContactEntity res = agent.GetMyBizCard();

Returns

Type Description
NSContactEntity The contact object with persons and interests.

GetMyContact()

Gets the contact belonging to the currently logged-on user.

Declaration

NSContactEntity GetMyContact()

Examples

NSContactAgent agent;
NSContactEntity res = agent.GetMyContact();

Returns

Type Description
NSContactEntity

GetMyContacts()

Gets the contacts where the user currently logged in is set as contact owner.

Declaration

NSContact[] GetMyContacts()

Examples

NSContactAgent agent;
NSContact[] res = agent.GetMyContacts();

Returns

Type Description
NSContact[] The contact.

GetMyRecentContacts(Integer)

Returns a set of initial contacts.

Declaration

NSContact[] GetMyRecentContacts(Integer sourceType)

Examples

NSContactAgent agent;
Integer sourceType;
NSContact[] res = agent.GetMyRecentContacts(sourceType);

Parameters

Type Name Description
Integer sourceType The source where the contacts are retrieved from (Favorites, History, Diary). See <xref href="CRMScript.NetServer.ContactSourceType" data-throw-if-not-resolved="false"></xref>.

Returns

Type Description
NSContact[] Array of contacts.

GetNameDepartmentDuplicates(String,String)

Gets duplicates based on the contact name and department

Declaration

NSDuplicateEntry[] GetNameDepartmentDuplicates(String name, String department)

Examples

NSContactAgent agent;
String name;
String department;
NSDuplicateEntry[] res = agent.GetNameDepartmentDuplicates(name, department);

Parameters

Type Name Description
String name Name used for lookup
String department Department used for lookup (if any).

Returns

Type Description
NSDuplicateEntry[] Any records matching the specified name and department.

GetPersons(Integer)

Returns an array of all the contact persons for the company card.

Declaration

NSPerson[] GetPersons(Integer contactId)

Examples

NSContactAgent agent;
Integer contactId;
NSPerson[] res = agent.GetPersons(contactId);

Parameters

Type Name Description
Integer contactId

Returns

Type Description
NSPerson[] Array of Persons.

GetQuoteVersionAddresses(Integer)

Gets the associated billing and invoice quote version addresses.

Declaration

NSAddress[] GetQuoteVersionAddresses(Integer quoteVersionId)

Examples

NSContactAgent agent;
Integer quoteVersionId;
NSAddress[] res = agent.GetQuoteVersionAddresses(quoteVersionId);

Parameters

Type Name Description
Integer quoteVersionId The version to get the addresses for.

Returns

Type Description
NSAddress[] The quote version addresses. Invoice and billing address, in that order.

IsNumberValid(Integer,String)

Checks if the number is unique or required. The setting is configured from admin under system options.

Declaration

Bool IsNumberValid(Integer contactId, String number)

Parameters

Type Name Description
Integer contactId
String number

Returns

Type Description
Bool

Merge(Integer,Integer,Bool,Bool)

Merges two contacts. The destination contact will remain.

Declaration

Void Merge(Integer sourceContactId, Integer destinationContactId, Bool mergeIdenticalPersons, Bool replaceEmptyFieldsOnDestination)

Parameters

Type Name Description
Integer sourceContactId Source contact to merge from. This contact will disappear after the merge.
Integer destinationContactId Destination contact to merge into
Bool mergeIdenticalPersons Persons with identical names will be merged
Bool replaceEmptyFieldsOnDestination If true, empty fields on destination will be replaced by values from source.

Returns

Type Description
Void

SaveContactEntity(NSContactEntity)

Updates the existing NSContactEntity or creates a new NSContactEntity if the ID parameter is 0.

Declaration

NSContactEntity SaveContactEntity(NSContactEntity contactEntityId)

Examples

NSContact  agent;
NSContactEntity thing = agent.CreateDefaultContactEntity();
thing = agent.SaveContactEntity(thing);

Parameters

Type Name Description
contactEntityId

Returns

Type Description
NSContactEntity The new or updated NSContactEntity.

SaveQuoteVersionAddress(Integer,NSAddress,Integer,Integer)

Saves a custom quote version address.

Declaration

NSAddress SaveQuoteVersionAddress(Integer quoteVersionId, NSAddress address, Integer addressType, Integer countryId)

Examples

NSContactAgent agent;
Integer quoteVersionId;
NSAddress address;
Integer addressType;
Integer countryId;
NSAddress res = agent.SaveQuoteVersionAddress(quoteVersionId, address, addressType, countryId);

Parameters

Type Name Description
Integer quoteVersionId The version to save the address on.
NSAddress address The address to save on the quote version.
Integer addressType Should be either QuoteBillingAddress or QuoteShippingAddress
Integer countryId The country for the custom address.

Returns

Type Description
NSAddress The saved addresses.

SetDuplicateRulesStatus(NSDuplicateRule[])

Sets which duplicate rules should be active or not

Declaration

Void SetDuplicateRulesStatus(NSDuplicateRule[] rules)

Parameters

Type Name Description
NSDuplicateRule[] rules Duplicate rules to update active status for.

Returns

Type Description
Void

Undelete(Integer)

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

Declaration

Void Undelete(Integer id)

Examples

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

Parameters

Type Name Description
Integer id The primary key of the entity to un-delete.

Returns

Type Description
Void

ValidateContactEntity(NSContactEntity)

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

Declaration

Map ValidateContactEntity(NSContactEntity contactEntity)

Examples

NSContactAgent agent;
NSContactEntity contactEntity;
Map res = agent.ValidateContactEntity(contactEntity);

Parameters

Type Name Description
NSContactEntity contactEntity

Returns

Type Description
Map