Skip to main content
Mitratech Success Center

Client Support Center

Need help? Click a product group below to select your application and get access to knowledge articles, webinars, training content, and release notes or to contact our support team.

Authorized users - log in to create a ticket, view tickets status and check your success plan details.

 

Object Definitions

The ObjectDefinitionService methods use the ObjectDefinition class to return information about object definitions.

An implementation of TeamConnect contains a variety of object definitions that are classified in one of the following ways:

  • System Object Definitions—Objects that exist as part of the core functionality of TeamConnect, before any customization. A TeamConnect implementation may utilize some, all, or none of the system objects. System objects include Account, Appointment, Contact, Document, Expense, History, Invoice, Involved, and Task.
  • Custom Object Definitions—Objects defined for a TeamConnect implementation. Custom objects could be Claims, Cases, Matters, Litigations, among others. They can have parent-child relationships with one another or you can define a custom object as an embedded object of another custom object, which is a child object with limited functionality.

An instance of an object is a record. For more details about system or custom objects, see About Objects.

ObjectDefinitionService Interface

If you want to retrieve object definitions using the API, you can use ObjectDefinitionService. As part of the ObjectDefinitionService interface, you can use the getObjectDefinition() method to retrieve an object definition. If the API cannot find an object definition that fits the unique code, the method throws an exception. The following code sample uses the getObjectDefinition() method to retrieve the contact object definition.

ObjectDefinition contactObjectDefinition = objectDefinitionService.getObjectDefinition("CONT");

In the following code sample, you can use the getObjectDefinition() method to retrieve a custom object definition with the unique code of MATT.

ObjectDefinition matterObjectDefinition = objectDefinitionService.getObjectDefinition("MATT");

Note: Use the following code to access ObjectDefinitionService: ObjectDefinitionService objectDefinitionService = platform.getObjectDefinitionService();

ObjectDefinition Interface

The ObjectDefinitionService methods use the ObjectDefinition class to return information about object definitions. ProjectObjectDefinition and InvolvedObjectDefinition also extends ObjectDefinition. The ObjectDefinition class includes the settings on the following pages of an object definition in the Setup:

  • General—The hasInvolved()isContactCentric(), and isNewBtnNotShownInRelObjBlock() methods refer to settings that might appear on the General page, depending on the type of object definition. If an object definition does not have the associated setting, the method returns false.
  • Wizards—The getRequiresWizardForCreate() method refers to whether or not the setting on the Wizards page specifies that a wizard is required to create a new record.

System Objects

System objects are the out-of-the-box objects included with TeamConnect. System objects allow you to do basic functions, such as creating contacts or invoices.

All system objects in the API each have a resource service class. These resource service classes use the API model interfaces to work with system fields. All system fields have get and set methods in their owner interfaces. You can also get or set custom fields on system objects.

Accounts

Accounts electronically track posted transactions, mainly expenses, tasks, and invoices. Use the AccountService class to access accounts in the API.

The API provides the following model interfaces for accounts:

  • The Account class, which contains information about the account.
  • The AccountInvolvedType class, which contains the enums for posting an account to a contact.
  • The AccountOverdraftType class, which contains the enums for how the account handles overdraft amounts.
  • The AccountPostingCriteria class, which contains information about the account and its posting criteria.
  • The AccountPostingStatus class, which contains the enums that indicate whether an expense, invoice, or task is posted to an account.
  • The AccountProjectType class, which contains the enums for posting a project to an account.
  • The AccountTransaction class, which contains information about an account transaction.
  • The AccountVendorType class, which contains the enums for posting a vendor to an account. Refer to the AccountService samples for examples of working with accounts in the API.

Refer to the AccountService samples for examples of working with accounts in the API.

Use AccountService when working with account records.

Whenever a Service operation requires AccountService, set up AccountService using the following code:

AccountService accountService = platform.getAccountService();

Creating an Account

The following sample creates an account record. During account creation, you can set objects in the account record, such as the account name.

Account newAccount = accountService.newAccount("name", allocationLimit, startOnDate, endOnDate);

Creating a Child Account

The following sample creates a child account record. During child account creation, you can use API interface methods to set objects in the account, such as the parent account.

Account newChildAccount = accountService.newAccount("name", 
allocationLimit, startOnDate, endOnDate);
newChildAccount.setParentAccount(parentAccount);

Reading an Account

The following sample reads an account record. When you read an account, you retrieve the account so that you can make changes to it, such as activating or transferring money from it.

//The id initialized here is the id of an existing account 
Long id = 1234567890L;
Account account = accountService.read(id);

Activating an Account

The following sample activates an account record.

accountService.activateAccount(accountToBeActivated);

Deactivating an Account  

The following sample deactivates an account record.

accountService.deactivateAccount(account);

Allocating Money to an Account  

The following sample allocates money to an account record. When you allocate money to an account, a parent account must already exist.

//Allocating money to an account - $5000 accountService.allocateMoney(account, amount, "description");

Transferring Money between Accounts  

The following sample transfers money between two accounts. When you transfer money, a parent and child account must already exist.

accountService.transferMoney(accountFrom, accountTo, amount, "description");

Withdrawing money from an Account  

The following sample withdraws money from an account record.
//Withdrawing from an account - $5000

Deleting an Account  

The following sample deletes an account record. When you delete an account, the account must not have a balance.

//Account cannot have a balance before deletion. Make necessary withdrawals.
accountService.withdrawMoney(parentAccount, new BigDecimal("1000"), "Withdraw to zero");
accountService.withdrawMoney(childAccount, new BigDecimal("234"), "Withdraw to zero");
//When deleting a parent account with attached child accounts, the child accounts also cannot have a balance. The deletion of a parent will delete its child accounts as well.
accountService.delete(parentAccount);

Appointments

Appointments are scheduled events or meetings with a date, time, and attendees. Use the AppointmentService class to access appointments in the API. The API provides the following model interfaces for appointments:

  • The Appointment class, which contains information about an appointment.
  • The AppointmentAttendee class, which contains information about an appointment attendee user and type.
  • The AttendanceType class, which contains the enums that indicate if a contact will attend an appointment.

Refer to the AppointmentService samples for examples of working with appointments in the API.

Use AppointmentService when working with account records.

Whenever a Service operation requires AppointmentService, set up AppointmentService using the following code:

AppointmentService appointmentService = platform.getAppointmentService();

Creating an Appointment  

The following sample creates an appointment. During appointment creation, you can use API interface methods to set objects in the appointment, including the start date, end date, and category.

// Retrieve the appointment service from the platform provided by the API 
AppointmentService appointmentService = platform.getAppointmentService();

// Set up the initial required arguments to create a valid appointment 
long fourDaysInMilliseconds = 86400000 * 4;
Date startOn = new Date();
Date endOn = new Date(startOn.getTime() + fourDaysInMilliseconds);

// Create a new appointment, passing in the arguments created above.
Appointment appointment = appointmentService("Appointment Subject", startOn, endOn);

// Any non-required fields on the appointment may be set or added now 
appointment.setAllDay(true); 
appointment.addCategory("APPT_CATE_CUST");

Updating an Appointment  

The following sample updates an appointment. When you update an appointment, you can use API interface methods to set objects in the appointment, including the primary key, new attendees, and custom fields.

Retrieve the appointment service from the platform provided by the API. 
AppointmentService appointmentService = platform.getAppointmentService();

// Retrieve the desired appointment. long primaryKeyForAppointment = 2;
Appointment appointment = appointmentService.read(primaryKeyForAppointment);

// Modify fields. appointment.addAttendee(platform.getUserService().findUserByUsername("TestUser"
), AttendanceType.WILL_ATTEND); 
appointment.setBooleanFieldValue("customBooleanField", false);

Deleting an Appointment  

The following sample deletes an appointment.

// Retrieve the appointment service from the platform provided by the API.
AppointmentService appointmentService = platform.getAppointmentService();

// An appointment can be deleted simply by passing in the primary key. 
long primaryKeyForAppointment = 8; appointmentService.delete(primaryKeyForAppointment);

// Or, you can pass in the appointment object.
Appointment appointment = appointmentService.read(primaryKeyForAppointment); 
appointmentService.delete(appointment);

// In a rule, the delete will be committed when the rule completes.
// Otherwise, the delete will be committed immediately.

Searching for an Appointment  

The following sample searches for all appointments in Room 101.

// Retrieve the appointment service from the platform provided by the API. 
AppointmentService appointmentService = platform.getAppointmentService();

// Find all appointments located in Room 101 SearchCriteria criteria = new SearchCriteria(new
StringCriterion(Appointment.LOCATION).equalTo("Room 101"));

// Sort results by start date
SearchParameters parameters = new SearchParameters(new SortField(Appointment.START_ON));

// Execute search and return results
return appointmentService.search(criteria, parameters);

Contacts

Contacts are people or companies for which your organization needs to store information, including employees, vendors, outside counsel, claimants, injured parties, witnesses, and agencies. Use the ContactService class to access contacts in the API.

The API provides the following model interfaces for contacts:

  • The Address class, which contains information about a contact address.
  • The Company class, which contains information that applies to only company contacts and extends the Contact class.
  • The Contact class, which contains information that applies to all contacts.
  • The ContactRelation class, which contains information about a contact relation.
  • The DefaultRate class, which contains information about a default rate for a contact.
  • The Email class, which contains information about a contact email address.
  • The FaxNumber class, which contains information about a contact fax number.
  • The InternetAddress class, which contains information about a contact web address.
  • The InvoiceTaskRate class, which contains information about an invoice task rate for a contact.
  • The Person class, which contains information that applies to only person contacts and extends the Contact class.
  • The PhoneNumber class, which contains information about a contact phone number.
  • The Skill class, which contains information about a contact skill.
  • The TaskRate class, which contains information about a task rate for a contact. Refer to the ContactService samples for examples of working with contacts in the API.

Refer to the ContactService samples for examples of working with contacts in the API.

Use ContactService when working with contact records.

Whenever a Service operation requires ContactService, set up ContactService using the following code:

ContactService contactService = platform.getContactService();

Creating a Person Contact  

The following sample creates a person contact record. During contact creation, you can use API interface methods to set objects in the contact record, including the contact address.

Person personContact = ContactService.newPerson("Bob", "Dole");
Address address = person.add
Address("ADDR_HOME");
address.setStreet("1234 Fake St.");
address.setCity("Austin");
address.setState("TX"); address.setPostalCode("78704"); 
address.setCountry("USA");

Creating a Company Contact  

The following sample creates a company contact record. During contact creation, you can use API interface methods to set objects in the contact record, including the contact address and email.

Company companyContact = ContactService.newCompany("myLittleCompany");
Address address = company.addAddress("ADDR_BUS1");
address.setStreet("1234 Fake St.");
address.setCity("Austin");
address.setState("TX");
address.setPostalCode("78704");
address.setCountry("USA");
Email email = company.addEmail("MAIL_BUS1", "you@yourcompany.com");

Updating a Contact  

The following sample updates a contact record. When you update a contact, you can use API interface methods to update objects in the contact record, including the contact fax number, email, and web address.

//Adding or updating a business fax number
FaxNumber faxNumber = person.addFaxNumber("FAXX_BUS1", "5123827322");

//Adding or updating a personal email
Email email = person.addEmail("MAIL_PER1", "you@yourcompany.com");

//Adding or updating a mobile phone number
PhoneNumber phoneNumber = person.addPhoneNumber("PHON_MOBI", "5123827322");

//Adding or updating a business web address
InternetAddress internetAddress = person.addInternetAddress("INET_BWEB", "www.mitratech.com");

//Adding or updating a default skill
Skill skill = person.addSkill("SKIL_DEFA", 2);

Reading a Contact  

The following sample reads a contact record. When you read a contact, you retrieve the contact so that you can make changes to it, such as updating or deleting it.

/The id initialized here is the id of an existing person contact 
long personId = 49L;
Person personContact = ContactService.readPerson(personId);
//The id initialized here is the id of an existing company contact 
long companyId= 23L;
Company companyContact = ContactService.readCompany(CompanyId);

Deleting a Contact  

The following sample deletes a contact record. When you delete a contact, if the contact is associated with a user or any other object, remove the association first.

ContactService.delete(personContact);
ContactService.delete(companyContact);

Documents

In addition to the Documents tab where you can save any document, all records have a Documents page where you can save documents to that record. When working with documents in the API, you have the ability to perform the same functionality that you can use with documents in TeamConnect. Use the DocumentService class to access with documents in the API.

The API provides the following model interfaces for documents:

  • The Document class, which contains information about a document. A document is anything that can appear in the documents list.
  • The Folder class, which contains information about a document folder.
  • The Hyperlink class, which contains a hyperlink.
  • The Shortcut class, which contains a shortcut.
  • The File class, which contains information about a file.
  • The FileContentType class, which contains information about the file type of a document.
  • The FileVersion class, which contains information for a file version.

Refer to the DocumentService samples for examples of working with documents in the API.

Use DocumentService when working with document records.

Whenever a Service operation requires DocumentService, set up DocumentService using the following code:

DocumentService documentService = platform.getDocumentService();

Creating a Document Record  

The following sample creates a document. During document creation, you can add the document to a folder, create a shortcut for the folder, and check in the file, among other things.

DocumentService documentService = platform.getDocumentService();

// Get attachment folder of a record Folder attachmentFolder =
documentService.getAttachmentFolderForDocumentOwner(getRecord());

// Create a folder under the attachment folder
Folder folder = attachmentFolder.addFolder("New Folder");

// Create a file directly under the attachment folder FileContentType contentType =
platform.getLookupItemService().getFileContentTypeByFileExtension("txt"); byte[] fileContent = new byte[0];
File file = attachmentFolder.addFile("New File", fileContent, contentType);

// Create a hyperlink
Hyperlink hyperlink = folder.addHyperlink("Mitratech", "http:// www.mitratech.com");

// Create a shortcut to a folder
Shortcut shortcutToFolder = folder.addShortcut(folder);

// Create a shortcut to a file
Shortcut shortcutToFile = folder.addShortcut(file);

//Checkout file 
documentService.checkOut(file);

//Checkin file
documentService.checkIn(file, fileContent, "check in comment");

Reading a Document Using its Path  

The following sample returns a document using its folder path.

// Returns a document from the repository using its folder path 
Document document = documentService.findDocumentByPath("path");

Retrieving the Root Folder  

The following sample returns the root document folder.

// Returns the root document folder
Folder rootFolder = documentService.getRootFolder();

Copying a Document  

The following sample copies a document to a new folder.

/ Returns an exact duplicate of a given entity object
Document duplicateDocument = documentService.copyEntity(originalDocument);

// Copies a document to a new parent folder
documentService.copyDocument(document, parentFolder);

Moving a Document  

The following sample moves a document to a new folder.

// Changes the location of a file 
documentService.moveDocument(document, parentFolder);

Checking Out a Document  

The following sample checks out a file and locks it so that other users cannot check it out.

// Checks out and locks a file for a single user to update 
documentService.checkOut(file);

Undoing a Document Checkout  

The following sample reverses a document checkout. The document remains unchanged and has no version number.

// Reverses the checkout of a file. documentService.undoCheckOut(file);

Checking in a Document  

The following sample checks in a document by converting the existing file to the new file version and replacing the file contents the byte array of the new contents.

// Checks in a file.
documentService.checkIn(file, data, "versionText");

Reverting a Document to a Previous Version  

The following sample reverts a document to a previous version by converting the existing file to a different file version and replacing the file contents with the byte array of the new contents.

// Revert a document to a prior version
FileVersion version = documentService.getFileVersions(file).get(0); 
documentService.revertTo(version);

Expenses

Expenses are internal costs for your business as a whole or that you can associate with an account. Use the ExpenseService class to access expenses in the API.
The API provides the Expense model interfaces for information about an expense.
Refer to the ExpenseService samples for examples of working with expenses in the API.
Use ExpenseService when working with expense records.

Whenever a Service operation requires ExpenseService, set up ExpenseService using the following code:

ExpenseService expenseService = platform.getExpenseService();

Creating an Expense  

The following sample creates an expense record. During expense creation, you can use API interface methods to set objects in the expense record, including the user who is responsible for the expense and a description of the expense.

//Expense description is a mandatory field
Expense expense = expenseService.newExpense("Brand New Test Description");
User user = platform.getUserService().findUserByUsername("Expenser");
expense.setExpensedBy(user);
//Date will be converted to midnight GMT, then back to the local date/time relative to GMT midnight
Calendar cal = Calendar.getInstance(); cal.set(2014, 01, 30); 
expense.setExpenseDate(new CalendarDate(cal));

Updating an Expense  

The following sample updates an expense record. When you update an expense, you can use API interface methods to update objects in the expense, including the expense name.

expense.setShortDescription("Expense Description Update");
//Adding new unit price for expensed item ($150) and quantity of units (2) 
expense.setUnitPrice(BigDecimal.valueOf(150)); 
expense.setQuantity(BigDecimal.valueOf(2));  

Reading an Expense

The following sample reads an expense record. When you read an expense, you can retrieve the last saved version of the expense to post, delete, or do something else with the record.

/The expenseHandle here is a preexisting Expense object
Expense lastSavedExpense = expenseService.readLastSaved(expenseHandle);

Posting an Expense  

The following sample posts an expense record. When you post an expense, you can use API interface methods to prepare an expense for posting.

//Ensure that these options are enabled in an account to post an expense account.setAllowPosting(true); account.getAccountPostingCriteria().setAllowExpense(true); expenseService.postExpense(expense)

Voiding an Expense

The following sample voids an expense record.

//An expense must be posted to be voided expenseService.voidExpense(expense);

Deleting an Expense  

The following sample deletes an expense record.

expenseService.delete(expense);

Getting Transactions for an Expense  

The following sample returns a list of transactions for an expense record.

List<AccountTransaction> transactions = expenseService.getTransactionsForExpense(expense);

Getting Transactions for an Expense Associated with an Account  

The following sample returns a list of transactions for an expense record that is associated with an account.

List<AccountTransaction> transactions = expenseService.getTransactionsForExpense(account, expense);

Searching for Expenses 

The following sample searches for expenses with a start date of January 2012.

Calendar cal = Calendar.getInstance(); 
cal.set(2012, 1, 1);
Date startDate = cal.getTime();

Calendar cal = Calendar.getInstance(); 
cal.set(2012, 1, 31);
Date endDate = cal.getTime();

DateCriterion dateCriterion = new 
DateCriterion(Expense.EXPENSE_DATE).between(startDate, endDate);

List<Expense> expenses = platform.getExpenseService().search(new 
SearchCriteria(dateCriterion));

Groups

In TeamConnect, a group exists independently of its group account record, meaning that if you need to get or set any information for a group, you must use the group account. All TeamConnect users have their own group accounts (instances of GroupAccount) that include information such as the group display name and description. Use the GroupService class to access with groups in the API.

The API provides the following model interfaces for groups:

  • The Group class, which contains the display name of the group. You can use this object to return the group name.
  • The GroupAccount class, which contains all the fields for the group account in TeamConnect. You can use this object to get or set information for a user.

Because every display name is unique, the group name connects a group to its group account. When you create a new group, TeamConnect generates a key that you can also use to identify the group. Use the entity.getPrimaryKey method if you want to identify the group with its key.

Because group rights determine the code you can run, it is sometimes necessary to check whether the current user is part of a group. You can get the current user using the UtilityService.getCurrentUser() method.

Refer to the GroupService samples for examples of working with groups in the API.

Use GroupService when working with group records.

Whenever a Service operation requires GroupService, set up GroupService using the following code:

GroupService groupService = platform.getGroupService();

Creating a Group  

The following sample creates a group. To create a group, you need to create a group account.

During group creation, you can use API interface methods to set objects in the group, such as its description.

//create a new group account with specified unique name and display name.
GroupAccount groupAccount = groupService.newGroupAccount("GroupUniqueName", 
"GroupDisplayName");
groupAccount.setDescription("Description");

Updating a Group  

The following sample updates a group. When you update a group, you can use API interface methods to update the group account, such as its description.

//get group with specified name.
Group group = groupService.getGroupForName("GroupName");

//retrieve the group account from the group.
GroupAccount groupAccount = groupService.getGroupAccountForGroup(group);
groupAccount.setDescription("newDescription");

Reading a Group  

The following sample reads a group. When you read a group, you retrieve the group account so that you can make changes to it, such as updating or deleting it.

//read group and user accounts.
GroupAccount groupAccount = groupService.read(1L); UserAccount userAccount = userService.read(1L);
//get the group and user from their corresponding accounts.
Group group = groupService.getGroupForGroupAccount(groupAccount); User user = userService.getUserForUserAccount(userAccount);
groupService.addUserToGroup(group, user);

Finding a Group  

The following sample finds a particular group. You can use the unique to find the group.

//get group based on its unique key.
Group group = groupService.getGroupForKey("uniqueKey");
//get all groups.
List<Group> allGroups = groupService.getAllGroups();
//get all users for a group.
List<User> usersForGroup = groupService.getAllUsersForGroup(group); //get all user accounts for group account.
GroupAccount groupAccount = groupService.read(1L); List<UserAccount> userAccountsForGroupAccount = groupService.getAllUserAccountsForGroupAccount(groupAccount);
//get all groups for a user.
User user = userService.findUserByUsername("username"); List<Group> groupsForUser = groupService.getGroupsForUser(user); 

Deleting a Group  

The following sample deletes a group by deleting the group account.

GroupAccount groupAccount = groupService.read(1L); 
groupService.delete(groupAccount);
//same as groupService.delete(groupAccount.getPrimaryKey());; 

History Entries

All records have a History or Narratives page, where you can save an entry with a general comment or information about an update to the record. When working with history entries in the API, you view current entries or create new entries. Use the HistoryService class to work with history entries in the API.

The API provides the History model interface for information about specific entries.
Refer to the HistoryService samples for examples of working with histories entries in the API.
Use HistoryService when working with history records.

Whenever a Service operation requires HistoryService, set up HistoryService using the following code:

HistoryService historyService = platform.getHistoryService();

Creating a History Entry  

The following sample creates a history entry. During history creation, you can use API interface methods to set objects in the entry, such as the history description and the category.

// Creates an empty history object.
History newHistory = historyService.newHistory("history", parentEntity);

Reading a History Entry  

The following sample returns a history entry using its primary key.

// Reads the Entity object based on the primary key provided historyService.read(primaryKey);

Finding a History Entry  

The following samples return all history entries for a particular entity and the most recent entry for an entity.

List<History> histories = historyService.getHistories(entity);
// Return most recent history with specified category and for a particular entity
History lastHistory = historyService.getLastHistory(entity, "HIST_STAT");

Deleting a History Entry  

The following samples delete a history entity.

// Deletes the Entity object
historyService.delete(history);
// Deletes the Entity object based on the primary key provided historyService.delete(primaryKey); 

Invoices

Invoices are bills that your organization receives from vendors and that you can post against accounts and projects. When working with invoices in the API, use the InvoiceService class.

The API provides the following model interfaces for invoices:

  • The Invoice class, which contains information about the invoice.
  • The InvoiceAdjustment class, which is the base class for all invoice adjustment classes and contains basic information about the adjustment.
  • The InvoiceAdjustmentTarget class, which contains the enums that indicate the amount being adjusted for the invoice summary.
  • The InvoiceAdjustmentType class, which contains the enums that indicate the type of invoice summary adjustment.
  • The InvoiceCategoryAdjustment class, which contains information about the invoice category adjustment, such as the task or expense code.
  • The InvoicePostingStatus class, which contains the enums that indicate the posting status of the invoice.
  • The InvoiceHeaderAdjustment class, which contains information about whether fees, expenses, or the total amount is the target of the header adjustment.
  • The InvoiceTimekeeperAdjustment class, which contains information about the timekeeper and the project associated with the adjustment.
  • The InvoiceType class, which contains the enums that indicate the type of invoice.
  • The LineItem class, which contains information about a line item.
  • The LineItemType class, which contains the enums that indicate the type of line item.
  • The AdjustmentInformation class, which contains information about the adjustments.
  • The AdjustmentMethod class, which contains the enums that indicate the method for adjusting the amount.

Refer to the InvoiceService samples for examples of working with invoices in the API.
Use InvoiceService when working with invoice records.
Whenever a Service operation requires InvoiceService, set up InvoiceService using the following code:

InvoiceService invoiceService = platform.getInvoiceService();

Creating an Invoice with Line Items  

The following sample creates an invoice and adds line items. During invoice creation, you can use API interface methods to set objects in the invoice record and line items, including the line item rate, quantity, discount, and total.

// vendor is an existing contact
Company vendor = platform.getContactService().readCompany(45L);

CalendarDate invoiceDate = new CalendarDate();
Invoice invoice = invoiceService.newInvoice("456", vendor, invoiceDate); //the line item original rate.
BigDecimal originalRate = new BigDecimal("23.00");
//the line item original quantity.
BigDecimal originalQuantity = new BigDecimal("500");
//the line item original discount.
BigDecimal originalDiscount = new BigDecimal("17.56");
//the line item original total.
BigDecimal originalTotal = new BigDecimal("34805743570");

LineItem newLineItem = invoiceService.newExpenseLineItem(invoice, invoiceDate,
"LNI$_EXPS_OCEX_E100_E101", originalRate,
originalQuantity).setOriginalDiscount(originalDiscount).setOriginalTotal(origina lTotal); 

Updating and Adjusting an Invoice  

The following sample updates and adjusts an invoice. When you update an invoice, you can use API interface methods to set objects in the invoice record, including the start date. You also use API interface methods to adjust an invoice, such as for reducing an amount to a new amount.

CalendarDate periodStartDate = new CalendarDate(); 
invoice.setPeriodStartDate(periodStartDate);
AdjustmentInformation information =
new AdjustmentInformation(AdjustmentMethod.REDUCE_BY_AMOUNT, 
new BigDecimal("45.00"));
invoiceService.adjustInvoiceFees(invoice, information); 

Adjusting Invoice Line Items  

The following sample adjusts an invoice line item. When you adjust a line item, you can use API interface methods to adjust the line item, such as changing a line item amount to a new amount.

AdjustmentInformation information =
new AdjustmentInformation(AdjustmentMethod.NEW_AMOUNT, new BigDecimal("22.56");
invoiceService.adjustLineItemRate(lineItemToAdjust, information); 

Reading an Invoice  

The following sample reads an invoice record. When you read an invoice, you retrieve the invoice so that you can make changes to it, such as updating or posting to it.

// id of existing invoice.
long id = 4982340L;
Invoice invoice = invoiceService.read(id); 

Searching for an Invoice  

The following sample searches for an invoice record.

// Returns all invoices that have an invoice date within the last 10 days
SearchCriteria criteria = new SearchCriteria(new RelativeDateCriterion(Invoice.INVOICE_DATE).withinLast(10));
List<Invoice> invoices = invoiceService.search(criteria);

Posting an Invoice  

The following sample posts an invoice.

invoiceService.postInvoice(invoiceToBePosted);

Voiding an Invoice  

The following sample voids an invoice.

invoiceService.voidInvoice(invoiceToBeVoided);

Deleting an Invoice  

The following sample voids an invoice.

invoiceService.delete(invoiceToBeDeleted);

Tasks

Tasks are internal assignments that you can bill to accounts if necessary. When working with tasks in the API, use the TaskService class.

The API provides the following model interfaces for tasks:

  • The Task class, which contains information about the task.
  • The TaskAssignee class, which contains information about the user assigned to a task.
  • The TaskPriority class, which contains the enums that indicate the priority of the task.
  • The TaskWorkStatus class, which contains the enums that indicate the status of the task.

Refer to the TaskService samples for examples of working with tasks in the API.

Use TaskService when working with task records.

Whenever a Service operation requires TaskService, set up TaskService using the following code:

TaskService taskService = platform.getTaskService();

Creating a Task  

The following sample creates a task record. During task creation, you can use API interface methods to set objects in the task record, including the current assignee, associated project, and task rate.

Project project = platform.getProjectService().read(0L);
User assignee = platform.getUserService().findUserByUsername("task assignee"); Task task = taskService.newTask("This is a new task", assignee); task.setActualHours(BigDecimal.TEN);
task.setRateAmount(BigDecimal.ONE);
task.setNote("Note: This is a new task");
task.setProject(project); 

Reading a Task  

The following sample reads a task record. When you read a task, you retrieve the task so that you can make changes to it, such as updating or posting to it.

//the primary key of an existing task long id = 12345678910L;
Task task = taskService.read(id);

Searching for Tasks  

The following sample searches for tasks with a start date of January 2012.

Date startDate = new SimpleDateFormat("yyyy-MM-dd").parse("2012-01-01");
Date endDate = new SimpleDateFormat("yyyy-MM-dd").parse("2012-01-31"); 
DateCriterion dateCriterion = new DateCriterion(new FieldPath(Task.START_DATE));

List<Task> tasksStartingInJanuary2012 = taskService.search(new SearchCriteria(dateCriterion.between(startDate, endDate))); 

Posting a Task  

The following sample posts a task record. When you post a task, you can use API interface methods to update the task at the same time.

//the primary key of an existing task
long id = 12345678910L;
Task task = taskService.read(id); 
task.setCompletedDate(new CalendarDate()); 
task.setCompletedPercent(BigDecimal.valueOf(100)); 
taskService.postTask(task); 

Voiding a Task  

The following sample voids a task record.

//the primary key of an existing task long id = 12345678910L;
Task task = taskService.read(id); taskService.voidTask(task);

Reassigning a Task  

The following sample reassigns a task to another user.

//the primary key of an existing task
long taskId = 12345678910L;
Task task = taskService.read(taskId);

//the primary key of an existing user
long userId = 12345678910L;
User user = platform.getUserService().findUserByUsername("new assignee");

taskService.reassign(task, user); 

Deleting a Task  

The following sample deletes a task record.

//the primary key of an existing task 
long taskId = 12345678910L;
Task task = taskService.read(id);
taskService.delete(task);

Getting a List of Transactions for a Task  

The following sample returns a list of transactions for a task record.

//the primary key of an existing task 
long taskId = 12345678910L;
Task task = taskService.read(id);

List<AccountTransaction> transactions = 
taskService.getTransactionsForTask(task);

Getting a List of Transactions for a Task associated with an Account  

The following sample returns a list of transactions for a task record that is associated with an account.

//the primary key of an existing task long taskId = 12345678910L;
Task task = taskService.read(id);

//the primary key of an existing account 
long accountId = 12345678910L;
Account account = accountService.read(id); 

Voiding a Task  

The following sample voids a task record.

//the primary key of an existing task long id = 12345678910L;
Task task = taskService.read(id); taskService.voidTask(task); 

Reassigning a Task  

The following sample reassigns a task to another user.

//the primary key of an existing task long id = 12345678910L;
Task task = taskService.read(id); taskService.voidTask(task); 
long taskId = 12345678910L;
Task task = taskService.read(taskId);
//the primary key of an existing user
long userId = 12345678910L;
User user = platform.getUserService().findUserByUsername("new assignee");
taskService.reassign(task, user); 

Deleting a Task  

The following sample deletes a task record.

//the primary key of an existing task long taskId = 12345678910L;
Task task = taskService.read(id);
taskService.delete(task); 

Getting a List of Transactions for a Task  

The following sample returns a list of transactions for a task record.

//the primary key of an existing task long taskId = 12345678910L;
Task task = taskService.read(id);
List<AccountTransaction> transactions = taskService.getTransactionsForTask(task); 

Getting a List of Transactions for a Task associated with an Account  

The following sample returns a list of transactions for a task record that is associated with an account.

//the primary key of an existing task long taskId = 12345678910L;
Task task = taskService.read(id);
//the primary key of an existing account long accountId = 12345678910L;
Account account = accountService.read(id); 

Users

In TeamConnect, a user exists independently of its user account record, meaning that if you need to get or set any information for a user, you must use the user account. All TeamConnect users have their own user accounts (instances of UserAccount) that include information such as username, password, and account status. Each user account is also linked to a contact record (instance of Contact) through the getContact() method. Use the UserService class to access with users in the API.

The API provides the following model interfaces for users:

  • The User class, which contains some read-only fields for the user. You can use this object to specify a user.
  • The UserAccount class, which contains all the fields for the user account in TeamConnect. You can use this object to get or set information for a user.
  • The UserType class, which contains the enums that indicate the type of user.

Because every username is unique, the username connects a user to its user account. When you create a new user, TeamConnect generates a key that you can also use to identify the user. Use the entity.getPrimaryKey method if you want to identify the user with its key.

Because you can change the user who is running the code, it is sometimes necessary to identify the current user. You can get the current user using the UtilityService.getCurrentUser() method.

Refer to the UserService samples for examples of working with users in the API.
Use UserService when working with user records.
Whenever a Service operation requires UserService, set up UserService using the following code:

UserService userService = platform.getUserService();

Creating a User  

The following sample creates a user record. You can use the newUser() and newUserAcccount() methods to create a user account and its associated user, the saveUserAccount() method to save the user, and the getUserForUserAccount() method to extract the user from its account.

During user creation, you can use API interface methods to set objects in the user record, including the corresponding contact, username, and password. Before creating a user, a corresponding contact record must already exist in TeamConnect or you must create a new contact using ContactService. As shown in the sample, when creating a user record, you must also create the user account.

//read or create a contact
Contact contact = contactService.readPerson(1L);

//create a limited privilege user account.
UserAccount limitedUserAccount = userService.newLimitedPrivilegeUserAccount("username", "password", contact, true);
limitedUserAccount.setActive(true); limitedUserAccount.setChangePasswordNextLogin(true);
limitedUserAccount.setShortDescription("Description for limited privilage user account");

//get user from limited privilege user account.
User limitedUser = userService.getUserForUserAccount(limitedUserAccount);

//create a normal user account.
UserAccount normalUserAccount = userService.newNormalUserAccount("username", "password", contact);
normalUserAccount.setActive(true); normalUserAccount.setChangePasswordNextLogin(true); normalUserAccount.setShortDescription("Description for normal user account"); //get user from normal user account.
User normalUser = userService.getUserForUserAccount(normalUserAccount);

//create a super user account.
UserAccount SuperPowerfulUserAccount = userService.newSuperUserAccount("username", "password", contact);
SuperPowerfulUserAccount.setActive(true); SuperPowerfulUserAccount.setChangePasswordNextLogin(true);
SuperPowerfulUserAccount.setShortDescription("Description for a super powerful user account");

//get user from super user account.
User superUser = userService.getUserForUserAccount(SuperPowerfulUserAccount); 

Updating a User  

The following sample updates a user record. When you update a user, you can use API interface methods to update fields in the user record, including the username, password, and active setting.

//read or create a user account.
UserAccount userAccount = userService.read(1L); 
userAccount.setUsername("newUsername"); 
userAccount.setPassword("newPassword"); 
userAccount.setActive(true); 

Reading a User  

The following sample reads a user record. When you read a user, you retrieve the user so that you can make changes to the user account, such as updating or deleting it.

//read a user account.
UserAccount userAccount = userService.read(1L);
//get the user from the user account.
User user = userService.getUserForUserAccount(userAccount); 

Finding a User  

The following sample find a particular user record. You can use a username to find the user.

User user = userService.findUserByUsername("username");

Deleting a User  

The following sample deletes a user record.

serAccount userAccount = userService.read(1L); 
userService.delete(userAccount);
//same as userService.delete(userAccount.getPrimaryKey()); 

Custom Objects

Custom objects are objects not included with TeamConnect Enterprise. The solution developer typically creates custom objects or they are included as part of a TeamConnect module, such as TeamConnect Legal. Custom objects are also called projects or matters.

Custom objects in the API have a resource service class for projects and Involved parties. These classes use the API model interfaces to work with the system fields of custom objects. All system fields have get and set methods in their owner interfaces. You can also get or set custom fields on custom objects.

Projects

Projects refer to custom objects with information that meets the business requirements of your organization. When working with projects in the API, use the ProjectService class.

The API provides the following model interfaces for projects:

  • The Project class, which contains information about the project.
  • The ProjectAssignee class, which contains information about a user assignees to a project.
  • The ProjectRelation class, which contains information about a contact related to the Involved party.

Refer to the ProjectService samples for examples of working with projects in the API.

Use ProjectService when working with project records.

Whenever a Service operation requires ProjectService, set up ProjectService using the following code:

ProjectService projectService = platform.getProjectService();

Adding an Embedded Project to a Parent Project  

The following samples update a project record by adding an embedded project to the project. As shown in these samples, you can use Project methods to add the embedded project.

EmbeddedEntity embeddedProject = project.addEmbeddedEntity("unique code"); //or
EmbeddedEntity embeddedProject = project.addEmbeddedEntityWithName("unique code", "name");
//or
EmbeddedEntity embeddedProject = project.addEmbeddedEntityWithNumberString("unique code", "id number as a string");
//or
EmbeddedEntity embeddedProject = project.addEmbeddedEntity("unique code", "name", "id number as a string"); 

Changing a Project's Phase  

The following sample changes the phase of a project and updates the record. While making these changes, you can use API interface methods to update objects in the project record, such as the project name.

project.setContact(contact); 
project.setMainAssignee(assignee);
projectService.changePhaseWithUpdate(project, "phase code of the phase to change to");

Reading Child Projects for a Record  

The following sample returns the child projects of a parent project.

List<Project> childProjects = projectService.getChildProjects(project, "unique code of the child Custom Object Definition");

Searching for a Project  

The following samples return an existing project. The second sample includes a

/Reading a project
//The id initialized here is the id of an existing project Long id = 1234567890L;
Project project = projectService.read(id);
//Searching for a project
List<Project> search("unique code", "search view key"); 

Deleting a Project  

The following sample deletes and existing project.

//The id initialized here is the id of an existing project Long id = 1234567890L;
projectService.delete(id);

Involved Parties

Involved parties are project participants that may not be TeamConnect users. When working with Involved parties in the API, use the InvolvedService class.

The API provides the following model interfaces for Involved parties:

  • The Involved class, which contains information about an Involved party.
  • The InvolvedRelation class, which contains information.

Refer to the InvolvedService samples for examples of working with Involved parties in the API.

Use InvolvedService when working with Involved party records.
Whenever a Service operation requires InvolvedService, set up InvolvedService using the following code:

InvolvedService involvedService = platform.getInvolvedService(); 

Adding an Involved Party to a Project

The following sample adds a new Involved party to a project.

During Involved party creation, you can to set objects in the Involved party record, including the Involved party unique code and the associated project.

 Involved newInvolved = involvedService.newInvolved(project, contact, 
 "INPA_EXPE"); 

Reading an Involved Party

The following sample returns an Involved party.

//The id initialized here is the id of an existing project Long id = 1234567890L
Involved involved = involvedService.read(id);  

Searching for an Involved Party

The following sample creates an Involved party record. The sample includes an InvolvedService.search() method. This search() method is different from the ResourceService.search() methods because the InvolvedService.search() method includes the unique code of an existing project as a parameter.

 List<Involved> involveds = involvedService.search("unique code", "search view key") 

Deleting an Involved Party

The following samples delete an Involved party record.

involvedService.delete(involved);
//or
//The id initialized here is the id of an existing project Long id = 1234567890L;
involvedService.delete(id); 

Related Records

Any system or custom object record can have related records. For example, contact and appointment records can have documents or histories related to them. In addition, project records can have related appointments, documents, histories, accounts, tasks, expenses, and child project records.

Do not confuse related objects with sub-objects, such as a contact's addresses or assignees of a project. To retrieve sub-objects, you must use the appropriate methods in the sub-object's owner interface.

The methods that you use to get related records depend on the types of related records. Projects have some methods for obtaining related records. In certain cases, to retrieve some related records, you must perform a search. Search for the following types of related records:

  • The following related records of system objects and projects: tasks, accounts, appointments, expenses, invoices, history entries, and documents.
  • Child accounts. While you can access the parent account from the child using Account.getParentAccount(), access child accounts of a parent by searching.

Getting Related Records of Projects

When you edit a field with a related record in a project record, you retrieve that field using the Project interface. When you cannot edit a related record field in the project record, the ProjectService interface has methods for retrieving information related to a project. Use the following methods to obtain related records for a project:

  • ProjectService.getChildProjects()—Retrieves all child projects records of a particular type related to a Project record.
  • ProjectService.getInvolved()—Retrieves all Involved party records related to a Project record.
  • Project.getParentProjecct()—Retrieves the parent project of a Project record.
  • Project.getEmbeddedProjects()—Retrieves all embedded project records of a particular type related to a Project record.
  • Project.getRelations()—Retrieves all projects related to a Project record. The API retrieves information about each relation using the ProjectRelation class.

NoteIn some cases, when you need to narrow down the list of related records you are looking for, you may need to search.

For complete samples in Java, see the Looping through Related Records of Projects and Copying Values from Parent to Multiple Child Records samples.

Using Custom Fields and Primary Keys to Relate Records

Certain situations require you to uniquely identify a system object record, such as a task or history record, that does not have a relationship to the current object record. To work around this situation, you can add a custom field to a record and store the primary key of another record to create a relationship. When you need to retrieve a record, you can use the primary key in this field. Typically, users do not see or modify this field.

For example, you might have a rule that creates a history record when someone creates a particular task for a project. After the task is complete, another rule might retrieve the history record and update it. In this situation, the project's history and the task have no direct relationship. To create a relationship, you can use the first rule to create a custom field in the task object definition and store the primary key of the history record. When you need to retrieve that history record in the second rule, you can use the custom field value.

The following code snippet demonstrates how the first rule retrieves the primary key of the history record and stores it in the custom field of a task:

// Store the primary key of the history in the record's custom field task.setNumberFieldValue("history", 
new BigDecimal(history.getPrimaryKey()));

The following code snippet demonstrates how a different rule retrieves the history record using its primary key in the custom field of a task record:

// Retrieving the primary key of the history from the record's custom field Long primaryKey = record.getNumberFieldValue("history").longValue();
// Retrieve the related history record
History retrievedHistory = platform.getHistoryService().read(primaryKey); 

Sub-Objects

Sub-objects contain information that exists only within a record. You cannot access the sub-objects outside that record. For example, categories, appointment attendees, contact addresses, invoice line items, and project assignees are all sub-objects.

Some sub-objects are also associated with the system lookup tables that define the individual types of sub-objects. For example, the Fax Type system lookup table defines the different types of fax numbers that you can add to a contact record.

Sub-Objects in the API  

Each sub-object is part of a main object. You retrieve sub-objects using a get method in the main object class. For example, if you want to retrieve a list of attendees for an appointment, use the Appointment.getAttendees method. If you want to retrieve the phone numbers for a contact, use the Contact.getPhoneNumbers method.

You can also add and remove sub-objects using the corresponding methods in the owner interfaces. For example, if you want to add an attendee to an appointment, use the Appointment.addAttendee method. If you want to remove an attendee from an appointment, use the Appointment.removeAttendee method.

Sub-Object Classes  

The following table includes all the frequently used sub-objects and their classes.

Sub-Objects of Main Team Connect Objects  

Main Object Class

Specific Sub-Object Classes

Account

(None)

Appointment

AppointmentAttendee

Contact

  • Address
  • Email
  • FaxNumber
  • InternetAddress
  • PhoneNumber
  • DefaultRate
  • TaskRate
  • InvoiceTaskRate
  • ContactRelation
  • Skill

Document

(None)

Expense

(None)

History

(None)

Involved

InvolvedRelation

Invoice

LineItem

Project

ProjectAssignee Phase ProjectRelation

Task

TaskAssignee

Project and Task Assignees

Assignees are sub-objects of users assigned to a project or task. The methods for assignees in respective Task and Project interfaces reflect the differences between task and project assignees.

Project and Task Assignee Differences  

Project Assignees

Task Assignees

Project assignees are instances of the ProjectAssignee interface.

Task assignees are instances of the TaskAssignee interface.

Projects can have multiple or no assignees. Projects with assignees always have one main assignee.

Tasks must have a current assignee and they can only have one assignee at a time.

By default, the user who creates a task record is set as the assignee of that task.

A project has a list of assignees that includes the main assignee, other active assignees, and inactive (unassigned) assignees.

A task includes a list of all previously assigned users as well as the current assignee.

You can remove (or unassign) a project assignee without adding a new one.

When you reassign a task, it adds the new assignee as the current assignee and unassigns the previously set assignee.

Each project assignee has an assignee role.

Task assignees do not have roles.

Instances of ProjectAssignee or TaskAssignee are always associated with a user. When you add an assignee to a task or project, you must provide a user in order to create the assignee.

For example, the Project.addAssignee() method assigns a project to an existing user, as shown in the following sample, and returns ProjectAssignee with the assigned user.

project.addAssignee("ROLE_TREE_POSI", user);

Contact Sub-Objects

Contacts have many sub-objects, including the sub-objects with the following interfaces:

  • Address
  • Email
  • FaxNumber
  • InternetAddress
  • PhoneNumber
  • DefaultRate
  • TaskRate
  • InvoiceTaskRate
  • ContactRelation
  • Skill

In some sub-object lists for a contact, one of the list items is the primary item. Specific methods for getting and setting the primary sub-objects are available in the Contact interface. For example, the phone and fax sub-objects have a primary phone number and a primary fax number. You can retrieve these primary sub-objects with the getPrimaryPhoneNumber() and getPrimaryFaxNumber() methods.

All of the sub-objects of contact have types, which describe the values you enter. Most sub-objects store these types in the system lookup tables, with the exception of the rate sub-objects. The rate sub-objects (DefaultRateTaskRate, and InvoiceTaskRate) are categories and instances of CategoryDefintion.

Categories

Categories have the following two purposes:

  • They provide a simple way to organize and search for records.
  • They organize custom fields by associating each custom field with a category. For custom fields to appear at all times, you can associate them with the root category. Users can display or hide custom fields by selecting or deselecting the associated categories.

In every object definition, the starting point for the category hierarchy is the root category. The hierarchy also includes a primary category, which the user sets manually. Upon record creation, the root category is set as the primary category.

Categories in the API  

In the API, you represent categories with the following interfaces:

  • CategoryService—The general category class that you use to obtain information about the categories for an object definitions or a tree position.

Note: Use the following code to access CategoryServiceCategoryService categoryService = platform.getCategoryService();

  • Category—The class that you use to obtain information about added categories and their hierarchical positions in a record, including any children and parent categories. A Category is an instance of a CategoryDefinition.
  • CategoryDefinition—The class that you use to obtain information about categories that exist for an object and their associated custom fields.
  • EnterpriseEntity—The class that includes methods that system objects and other interfaces extend. This class includes the getAllCategories()getPrimaryCategory()hasCategory(), and setPrimaryCategory() methods.
  • Object model interfaces with categories—These class also have methods for getting and setting categories. For example, the Invoice class has the following methods: addCategory()getCategories(), and removeCategory(). Other object model interfaces may have different category methods.

NoteIn instances of an Involved object, categories are known as "involved roles."

Category Tree Positions  

A full tree position uniquely identifies a category. The root category's full tree position is the same as the unique code of the object definition. The full tree position of non-root categories is a combination of the following with underscores as delimiters:

  • The full tree position of the category's parent category
  • The partial tree position of the category itself

For example, category B with partial tree position BBBB is under category A with partial tree position AAAA, which is under the root category of the Appointment object definition with the unique code APPT. As a result, the full tree position of category B is APPT_AAAA_BBBB, and the full tree position of category A is APPT_AAAA.

Adding or Deleting Categories in Records

If you want to select a category for a record, you can use the addCategory() method from the object's model class. The following code sets External, with a tree position of CONT_EXTE, as a category for a contact:

contact.addCategory("CONT_EXTE");

If you want to deselect a category from a record, you can use the removeCategory() method from the object's model class. The following code removes External from the list of selected categories for a contact:

contact.removeCategory("CONT_EXTE");

For a sample, see Updating Added Categories.

Returning Categories for a Record

If you want to know the categories that are selected for a record, you can use the EnterpriseEntity.getAllCategories() method. The following code returns all selected categories, including the parent categories, for a contact:

List<Category> allCategories = contact.getAllCategories();

If you want to know the lowest-level categories that are selected for a record, you can use the getCategories() method from the object's model class. The lowest-level categories include all the categories that do not have any child categories. If a selected category has lower-level categories that are not selected, getCategories() only returns the selected category. For example, the circled categories in the following image are the lowest-level selected categories.

image

If the contact record has the categories selected in the previous image, the following code returns the ContactFederalCourt, and Expert categories for the contact:

List<Categories> categories = contact.getCategories();

In this example, the code does not return Agency because Federal is a lower level category, and it returns Court because none of the lower level categories for Court are selected.

Getting and Setting Primary Categories

If you want to set the primary category of an object, you can use the EnterpriseEntity.setPrimaryCategory() method. The following code sample provides an example of how to create a new contact and set its primary category:

// Retrieve the contact service
ContactService contactService = platform.getContactService();
// Create a new, blank contact. The vendor record is a contact which has // previously been created. Set some categories for the contact record Contact contact = contactService.newCompany("vendor"); contact.setPrimaryCategory("CONT_EXTE_LAWF"); contact.addCategory("CONT_EXTE_VEND");
// Save the contact to the database contactService.create(contact); 

If you want to return the primary category of an object, you can use the EnterpriseEntity.getPrimaryCategory() method. The following code sample returns the primary category of a contact:

Category primaryCategory = contact.getPrimaryCategory();

For a complete sample, see the Checking the Default Role in Related Involved Records sample.

Checking Records for Specific Categories

To return whether a record has a particular category, you can use the hasCategory() method and the full tree position of the category. The following code sample checks if a contact has the "Vendor" category:

boolean isVendor = contact.hasCategory("CONT_EXTE_VEND");

For a sample, see the Checking Lists of Added Categories sample.

Custom Fields

Custom fields exist for capturing your organization's custom information in TeamConnect. You create custom fields within object definitions under categories in an object. Within records in TeamConnect, users make custom fields available by selecting the categories with that custom field. Custom fields that appear at all times are under the root category.

In the TeamConnect API, the following interfaces represent custom field information:

  • EnterpriseEntity and Project—You use methods in these classes to get and set custom fields, depending on the custom field type.
  • CustomField—You use this class to retrieve information about a custom field. You mainly use this custom field and its subclasses when constructing search criteria.

Requirements for Getting or Setting Custom Field Values

You can get and set most custom fields using methods in the EnterpriseEntity interface. The Project interface has methods to get and set custom fields of Involved type.

To get or set a value in a custom field, you need the following information to locate the necessary field:

  • (If the field is not under a root category) The full tree position of the category for the field. You can find the full tree position of a category in the UI of the TeamConnect Setup.
  • The name of the custom field, not its label.

You can find field names on the Custom Fields tab of the corresponding object definition in the TeamConnect user interface.

  • The type of custom field.

Depending on the field type, you use different methods to get or set the value in the custom field.

The following table lists all the methods from the EnterpriseEntity and Project interfaces that allow you to get or set custom field values according to field type.

Custom Field Types and Method Names  

Field Type

get and set Methods

Class(es) with Methods

Check Box (Boolean)

getBooleanFieldValue() setBooleanFieldValue()

EnterpriseEntity

Date

getDateFieldValue() setDateFieldValue()

EnterpriseEntity CalendarDate

Involved

getInvolvedFieldValue() setInvolvedFieldValue()

Project

List

getLookupFieldValue() setLookupFieldValue()

EnterpriseEntity

Memo (Text)

getMemoFieldValue() setMemoFieldValue()

EnterpriseEntity

Number

getNumberFieldValue() setNumberFieldValue()

EnterpriseEntity

Custom Object

getProjectFieldValue() setProjectFieldValue()

EnterpriseEntity

Text

getTextFieldValue() setTextFieldValue()

EnterpriseEntity

You can retrieve custom fields from any of the objects that extend EnterpriseEntity, as shown in the following code:

record.getCalendarDateFieldValue("fieldName"); record.getLookupFieldValue("fieldName");

If a custom field is part of a non-Root category, you must include the tree position when retrieving the value of the custom field:

record.getBooleanFieldValue("TREE_POSI", "fieldName"); record.getLookupFieldValue("TREE_POSI", "fieldName");

In the following code sample, you can get the value of the LossAmount custom field of type Number, which has a category with the full tree position CLAM_FEAT:

record.getNumberFieldValue("LossAmount", "CLAM_FEAT");

For a complete sample, see the Comparing Custom Field Qualifiers sample.

You can set different kinds of values for custom fields of objects that extend EnterpriseEntity. To set a value in a list custom field, you can enter a field name and the value using EnterpriseEntity methods, as shown in the following code:

record.setBooleanFieldValue(fieldName, true); record.setLookupFieldValue(categoryTreePosition, fieldName, "ITEM");

In the following code sample, you can set the value of the memo field OtherDistractions and use its category full tree position of CLAM_FEAT:

record.setMemoFieldValue("CLAM_FEAT", "OtherDistractions", "Claimant was reading a map.");

For a complete sample, see the Checking and Setting Values in Custom Fields of Type List sample.

Lookup Table Fields

Lookup tables provide options in List fields of TeamConnect. Each option in a List field is a lookup table item. TeamConnect has two types of lookup tables:

  • System lookup tables that TeamConnect includes by default. You can modify them by adding and removing items, but you cannot delete them.
  • Custom lookup tables that you can create as custom fields. Unlike system lookup tables, you can delete custom lookup tables. However, determine whether other design components are dependent on the custom lookup table before deleting it.

Because items in a lookup table have hierarchical relationships between them, you can use full tree positions to uniquely identify all lookup table items. Tree positions for system lookup tables and custom lookup tables are different.

Lookup Tables in the API  

In the API, you represent lookup tables and their items with the following interfaces:

  • LookupItemService—Includes methods that you use to return information about lookup tables and items. For example, you can use the getCustomLookupItems() method to retrieve a list of items in a custom lookup table:
lookupItemService.getCustomLookupItems("CODE");

Note: Use the following code to access LookupItemServiceLookupItemService lookupItemService = platform.getLookupItemService();

  • LookupItem—Includes methods for retrieving information about lookup table items. For example, the following code uses the getStoredValue() method to retrieve the stored value of a lookup table item:
contact.getLookupFieldValue("categoryFullTreePosition", "fieldName").getStoredValue();
  • EnterpriseEntity—Includes methods that system objects and other interfaces extend. For example, you can use the getLookupFieldValue() method with the Contact model interface to return the value for a custom lookup field:
contact.getLookupFieldValue(String treePosition, String fieldName);

LookupItemService Interface  

Most LookupItemService methods return information about the following types of lookup tables and lookup table items:

  • System lookup tables—You can retrieve all system lookup tables. Each system lookup table in TeamConnect has a LookupItemService method. For example, use lookupItemService.getContactPhoneNumberTypes() to return a list of the lookup table items for the phone number field in a contact.
  • Custom lookup tables—You can retrieve a custom lookup table and item. getCustomLookupItemForTreePostion() returns one item in a lookup table, and getCustomLookupItems() returns the list of items in a custom lookup table.
  • Currency—You can retrieve and update the currency lookup table. getCurrencyItemList() returns the list of currencies in the lookup table, and updateCurrencyRates() adds a currency entry to the lookup table.
  • Expenses—You can retrieve information about an expense category. readLineItemExpenseCode() returns an item in the expense category lookup table, and readLineItemExpenseUnitPrice() and readExpenseRateScaleValue() return rates and units associated with a category.
  • Document types—You can retrieve document types. For example, getAllDocumentTypes() returns the list of document types in a lookup table.

System Lookup Table Tree Positions

The full tree position of a system lookup table item is a combination of the following codes with underscores as delimiters:

  • The full tree position of the lookup item's parent item.
  • The partial tree position of the item.

In the following image, the Territory Type lookup table in contact records has the code of TERR. If Orange County has the partial tree position OCNT and Southern California has the partial tree position SOCA, the full tree position of Orange County is TERR_SOCA_OCNT.

Screen Shot 2017-09-19 at 4.26.22 PM.png

The following code samples provide examples of how you can use the tree position to retrieve a system lookup table item.

LookupItemService lookupItemService = platform.getLookupItemService();

// Retrieving the “Apple” item within the Fruits custom table
CustomLookupItem apple = lookupItemService.getCustomLookupItemForTreePosition("FRUI_APPL");

// Retrieve all items in the Fruits custom table
List<CustomLookupItem> fruits = lookupItemService.getCustomLookupItems("FRUI");

// Retrieving the “Mobile” item within the Phone Type system table;
SystemLookupItem mobile = lookupItemService.getSystemLookupItemForTreePosition("PHON_MOBI"); 

The following table includes all system lookup tables, their associated LookupItemService method, and their unique codes. Use the unique code of each system lookup table at the beginning of the full

tree position for a lookup table item. The table also lists API model interfaces associated with the lookup tables. If the lookup tables are not associated with a string field, the API class column does not apply.

System Lookup Table Names  

Friendly name

Associated LookupItemService method

Associated API class

Unique code

Activity Item

getActivityItems()

N/A

ACTI

Address Type

getContactAddressTypes()

Address

ADDR

Contact Relation Type

getContactRelationTypes()

ContactRelation

CONR

Country Item

getCountries()

N/A

COUN

Email Type

getContactEmailTypes()

Email

MAIL

Fax Type

getContactFaxNumberTypes()

FaxNumber

FAXX

Internet Address Type

getContactInternetAddressT ypes()

InternetAddress

INET

Invoice Rejection Reason

getInvoiceRejectionReason(

)

N/A

INRR

Phone Type

getContactPhoneNumberTypes ()

PhoneNumber

PHON

Project Assignee Type

getProjectAssigneeRoles()

ProjectAssignee

Unique code of the respective custom object definition.

Project Relation Type

getProjectRelationTypes()

ProjectRelation

PRJR

Resource Type

getAppointmentResourceType s()

N/A

RESO

Skill Type

getContactSkillTypes()

Skill

SKIL

Territory Type

getContactTerritoryTypes()

N/A

TERR

State Item

getStatesForCountryCode()

N/A

STAT

Custom Lookup Table Tree Positions

When you create a custom lookup table, you specify the unique code of the lookup table in the form of a 4-character alphanumeric combination. For example, the unique code of the Occupations custom lookup table might be OCCU.

The full tree position of the root node includes the unique code of the custom lookup table and ROOT. For example, the full tree position of the root node of the Occupations lookup table is OCCU_ROOT.

The full tree position of non-root custom lookup table items include the following with underscores as delimiters:

  • The unique code of the custom lookup table.
  • The partial tree position of the root node (ROOT).
  • The partial tree position of any parent items.
  • The partial tree position of the item.

For example, the Occupations custom lookup table in the following image has an HR Associate item with a partial tree position of HRAS and a Human Resources item with the partial tree position HURE. As a result, the full tree position of the HR Associate item is OCCU_ROOT_HURE_HRAS.

Screen Shot 2017-09-19 at 4.26.52 PM.png

The following code samples provide examples of how you can use the tree position to retrieve a custom lookup table item.

lookupItemService.getCustomLookupItemForTreePosition("treePosition");

//Retrieving “Big Budget Hits” custom item in the “Released Movies” custom table 
//Table Code: RMOV, Item Tree Position: BBHT
CustomLookupItem movie = lookupItemService.getCustomLookupItemForTreePosition("RMOV_ROOT_BBHT");

//Retrieving “Comedy” child item of the “Big Budget Hits” custom item 
//Table Code: RMOV, Item Tree Position: CMDY

CustomLookupItem comedy = lookupItemService.getCustomLookupItemForTreePosition("RMOV_ROOT_BBHT_CMDY"); 

Getting or Setting Values in List Custom Fields

The following sections demonstrate how to get or set values in List custom fields.

Getting Values in Lists  

The EnterpriseEntity.getLookupFieldValue() method retrieves the item selected for a List custom field. You can use this value, which is a LookupItem object, to retrieve the full tree position of the lookup item. The following code provides an example of how you can retrieve the full tree position of a List custom field in the contact object:

contact.getLookupFieldValue("APPT_AAAA_BBBB", "HR Associate").getKey();

In addition to contacts, you can use this code for any objects that extend EnterpriseEntity, such as projects or expenses.

Setting Values in Lists  

When you set values in List custom fields, you must include the following information:

You can use the EnterpriseEntity.getLookupFieldValue() without the full tree position of the category, as shown in the following code sample.

contact.setLookupFieldValue("HR Associate", "OCCU_ROOT_HURE_HRAS");

If you know the tree position, you can also use it as one of the parameters for the method:

contact.setLookupFieldValue("APPT_AAAA_BBBB", "HR Associate", "OCCU_ROOT_HURE_HRAS");

For a complete sample of custom list fields in Java, see Checking and Setting Values in Custom Fields of Type List.

  • Was this article helpful?