Show/Hide Toolbars

Creating a project record is done using the ProjectRepository object. For example, use the ProjectRepository's insertProject (ProjectCreate project) method. The resulting record's unique key is returned. The insertProject call will result in a SOAP/HTTP request and requires authentication.

When creating a project you can also add one or more assignees. From the type class, ProjectCreate, you need to use the getAssigneeCreates() method (see the example below for how to add items to the resulting list of ProjectAssigneeCreate).

Before you can start, you must get the unique key for the target assignee role and the unique key for the user to add as assignee either from the TeamConnect Designer GUI or from the database.

Note: After you understand how to add assignees to a project, you can apply a similar concept to the procedure for adding relations to a project.

Code Snippet

//in the sample below, basic require fields are commented but it is recommended to verify whether additional required fields have been defined from the TeamConnect  custom object definition or from the responsible solution developer

protected ProjectRepository projectRepository;

ProjectCreate project = createProject();

projectRepository.insertProject(project);

private ProjectCreate createProject() throws Exception {

Date date = new Date();

//the EntityTypeUniqueKey is an object's 4-character unique code; look this value up either in the Designer area Object Definitions list or from the database

String Entity_Type_Unique_Key = "DISP";

ProjectCreate project = new ProjectCreate();

//entityTypeUniqueKey is a required field

project.setEntityTypeUniqueKey(Entity_Type_Unique_Key);

//name is a required field

project.setName("Small Claims Forster vs. Gloucster");

//idNumber is a required field

project.setIdNumber("Dispute_1001");

project.setClosedOn(date);  

//the next three lines add a category to the project

Category cat = new Category();

cat.setUniqueKey("DISP EXTE");

project.getCategories().add(cat);

//the next four lines create a placeholder for an existing Text custom field, identify the known custom field name (statusSummary), set the custom field value, and add the custom field placeholder to its parent category

TextCustomField statusSummary = new TextCustomField();

statusSummary.setFieldName("statusSummary");

statusSummary.setValue("Dispute has been resolved. Settlement reached.");

cat.getTextCustomFields().add(statusSummary);

project.getAssigneeCreates().addAll(getAssigneeCreates());

return project;

}

public List<ProjectAssigneeCreate> getAssigneeCreates() {

Date date = new Date();    

List<ProjectAssigneeCreate> assignees = new List<ProjectAssigneeCreate>();

ProjectAssigneeCreate assignee1 = new ProjectAssigneeCreate();

assignee1.setRoleUniqueKey("RPRT");

assignee1.setAssignedOn(date);

assignee1.setUnassignedOn(date);

assignee1.setUserUniqueKey("USER9614");

assignee1.setActive(True);

assignees.add (assignee1);

ProjectAssigneeCreate assignee2 = new ProjectAssigneeCreate();

assignee2.setRoleUniqueKey("RPRT");

assignee2.setAssignedOn(date);

assignee2.setUnassignedOn(date);

assignee2.setUserUniqueKey("USER9630");

assignee2.setActive(False);

assignees.add (assignee2);

return assignees;

}