Show / Hide Table of Contents

Class NSContactAgent

Contact (company) data services.

Syntax
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)
Parameters
Type Name Description
Integer contactId

Contact to add person to

NSPersonEntity newPersonEntity

Person object to add.

Returns
Type Description
NSPersonEntity

Updated person object.

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

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
Examples
NSContactAgent agent;
agent.callMethod(arg1, arg2);

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)
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.

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

CreateDefaultContactEntity()

Sets default values into a new NSContactEntity.

Declaration
NSContactEntity CreateDefaultContactEntity()
Returns
Type Description
NSContactEntity

New ContactEntity with default values.

Remarks

NetServer calculates default values (for example, Country) on the entity, which is required when creating/storing a new instance

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

CreateNewEntry(NSDuplicateEntry)

Creates a new contact based on external duplicate

Declaration
Integer CreateNewEntry(NSDuplicateEntry 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.

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

DeleteContactEntity(Integer)

Deletes the NSContactEntity

Declaration
Void DeleteContactEntity(Integer contactEntity)
Parameters
Type Name Description
Integer contactEntity

The identity of the ContactEntity.

Returns
Type Description
Void
Examples
NSContactAgent agent;
agent.DeleteContactEntity(123);

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
Examples
NSContactAgent agent;
agent.callMethod(arg1, arg2);

GetAddress(Integer)

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

Declaration
LocalizedField[][]GetAddress(Integer contact Id)
Parameters
Type Name Description
Integer contactId

The contact Id.

Returns
Type Description
Examples
NSContactAgent agent;
Integer contactId;
NSAddress res = agent.GetAddress(contactId);

GetAddressByCountry(Integer,Integer)

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

Declaration
LocalizedField[][] GetAddressByCountry(Integer contactId, Integer countryId)
Parameters
Type Name Description
Integer contactId

The contact ID

Integer countryId

The country Id.

Returns
Type Description
Examples
NSContactAgent agent;
Integer contactId;
Integer countryId;
NSAddress res = agent.GetAddressByCountry(contactId, countryId);

GetContact(Integer)

Gets an NSContact object.

Declaration
NSContact GetContact(Integer contactId)
Parameters
Type Name Description
Integer contactId

The identifier of the Contact object.

Returns
Type Description
NSContact
Examples
NSContactAgent agent;
NSContact thing = agent.GetContact(123);

GetContactEntity(Integer)

Gets an NSContactEntity object.

Declaration
NSContactEntity GetContactEntity(Integer contactEntityId)
Parameters
Type Name Description
Integer contactEntityId

The identifier of the ContactEntity object.

Returns
Type Description
NSContactEntity
Examples
NSContactAgent agent;
NSContactEntity thing = agent.GetContactEntity(123);

GetContactList(Integer[])

Gets an array of Contact objects.

Declaration
NSContact[] GetContactList(Integer[] contactIds)
Parameters
Type Name Description
Integer[] contactIds

Array of identifiers for Contact.

Returns
Type Description
NSContact[]

Array of NSContact.

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

GetContactSummary(Integer,Integer)

Gets summary of contact and its recent activity.

Declaration
NSContactSummary GetContactSummary(Integer contactId, Integer 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.

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

GetContactWithPersons(Integer)

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

Declaration
NSContactEntity GetContactWithPersons(Integer contactId)
Parameters
Type Name Description
Integer contactId

The ID of the contact.

Returns
Type Description
NSContactEntity

ContactEntity with all data and persons.

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

GetDuplicateRules()

Retrieves all available duplicate rules for contact

Declaration
NSDuplicateRule[] GetDuplicateRules()
Returns
Type Description
NSDuplicateRule[]

All available duplicate rules.

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

GetDuplicates(String)

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

Declaration
NSDuplicateEntry[] GetDuplicates(String name)
Parameters
Type Name Description
String name

Name used for lookup.

Returns
Type Description
NSDuplicateEntry[]

Any records matching the specified name.

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

GetMyActiveContacts(DateTime,Integer[],Integer)

Returns the contacts where there has been activity since activityStartTime.

Declaration
NSContactActivity[] GetMyActiveContacts(DateTime activityStartTime, Integer[] contactCategories, Integer 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 ContactAction.

Returns
Type Description
NSContactActivity[]

Array of contacts where there have been activity in the period.

Remarks

If activityStartTime is larger than the current date, all contacts with activity since the last log-out are returned. The result set can be filtered by category and action type.

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

GetMyBizCard()

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

Declaration
NSContactEntity GetMyBizCard()
Returns
Type Description
NSContactEntity

The contact object with persons and interests.

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

GetMyContact()

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

Declaration
NSContactEntity GetMyContact()
Returns
Type Description
NSContactEntity
Examples
NSContactAgent agent;
NSContactEntity res = agent.GetMyContact();

GetMyContacts()

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

Declaration
NSContact[] GetMyContacts()
Returns
Type Description
NSContact[]

The contact.

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

GetMyRecentContacts(Integer)

Returns a set of initial contacts.

Declaration
NSContact[] GetMyRecentContacts(Integer sourceType)
Parameters
Type Name Description
Integer sourceType

The source where the contacts are retrieved from (Favorites, History, Diary). See ContactSourceType.

Returns
Type Description
NSContact[]

Array of contacts.

Remarks

This could be the contacts in a favorites selection, the history list, the diary, or from all sources. If retrieved from the diary it will get appointments for the current and the next day.

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

GetNameDepartmentDuplicates(String,String)

Gets duplicates based on the contact name and department

Declaration
NSDuplicateEntry[] GetNameDepartmentDuplicates(String name, String 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.

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

GetPersons(Integer)

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

Declaration
NSPerson[] GetPersons(Integer contactId)
Parameters
Type Name Description
Integer contactId
Returns
Type Description
NSPerson[]

Array of Persons.

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

GetQuoteVersionAddresses(Integer)

Gets the associated billing and invoice quote version addresses.

Declaration
NSAddress[] GetQuoteVersionAddresses(Integer 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.

Remarks

These addresses might be address on the contact, or a custom address.

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

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
Examples
NSContactAgent agent;
agent.callMethod(arg1, arg2);

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
Examples
NSContactAgent agent;
agent.callMethod(arg1, arg2);

SaveContactEntity(NSContactEntity)

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

Declaration
NSContactEntity SaveContactEntity(NSContactEntity contactEntityId)
Parameters
Type Name Description
contactEntityId
Returns
Type Description
NSContactEntity

The new or updated NSContactEntity.

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

SaveQuoteVersionAddress(Integer,NSAddress,Integer,Integer)

Saves a custom quote version address.

Declaration
NSAddress SaveQuoteVersionAddress(Integer quoteVersionId, NSAddress address, Integer addressType, Integer 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.

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

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
Examples
NSContactAgent agent;
agent.callMethod(arg1, arg2);

Undelete(Integer)

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

Declaration
Void Undelete(Integer id)
Parameters
Type Name Description
Integer id

The primary key of the entity to un-delete.

Returns
Type Description
Void
Examples
NSContactAgent agent;
Integer id;
agent.Undelete(id);

ValidateContactEntity(NSContactEntity)

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

Declaration
Map ValidateContactEntity(NSContactEntity contactEntity)
Parameters
Type Name Description
NSContactEntity contactEntity
Returns
Type Description
Map
Examples
NSContactAgent agent;
NSContactEntity contactEntity;
Map res = agent.ValidateContactEntity(contactEntity);
In This Article
  • Constructors
    • NSContactAgent()
  • Methods
    • AddPerson(Integer,NSPersonEntity)
    • ChangeCountry(NSContactEntity,Integer)
    • Copy(Integer,String,String,Bool)
    • CreateDefaultContactEntity()
    • CreateNewEntry(NSDuplicateEntry)
    • DeleteContactEntity(Integer)
    • DeleteExpired()
    • GetAddress(Integer)
    • GetAddressByCountry(Integer,Integer)
    • GetContact(Integer)
    • GetContactEntity(Integer)
    • GetContactList(Integer[])
    • GetContactSummary(Integer,Integer)
    • GetContactWithPersons(Integer)
    • GetDuplicateRules()
    • GetDuplicates(String)
    • GetMyActiveContacts(DateTime,Integer[],Integer)
    • GetMyBizCard()
    • GetMyContact()
    • GetMyContacts()
    • GetMyRecentContacts(Integer)
    • GetNameDepartmentDuplicates(String,String)
    • GetPersons(Integer)
    • GetQuoteVersionAddresses(Integer)
    • IsNumberValid(Integer,String)
    • Merge(Integer,Integer,Bool,Bool)
    • SaveContactEntity(NSContactEntity)
    • SaveQuoteVersionAddress(Integer,NSAddress,Integer,Integer)
    • SetDuplicateRulesStatus(NSDuplicateRule[])
    • Undelete(Integer)
    • ValidateContactEntity(NSContactEntity)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top