Polls

By using polls, teamspace members can offer multiple-choice questions to other members. Polling features include the ability to prioritize polls and allow comments from respondents. Closed polls and their data may be stored, retrieved, and searched.

The Collaboration API contains elements that developers can use to create, access, and manage polls from within FileNet P8 applications. Key polling elements are:

Polling Fundamentals

A poll comprises the following basic information:

A poll is established when the above information is added to a PollInfo object and passed to a FolderContainer object. Participants may then respond to the poll, with or without comments, through the Poll object's respond method. Polling continues until the closing date/time is met or when the creator-owner of the poll closes the survey through the Poll object's close method.

Creating a Poll

The following code describes how a Poll object might be created in a known object store and teamspace. For information on teamspace objects, see Teamspaces; for information on creating and managing object stores, see the Content Java API topic, Working With Object Stores.

    // pass basic poll construction data to a new PollInfo object
    PollInfo pollInfo = new PollInfo();

    ArrayList participantIdList = new ArrayList();
SubjectInfo subjectInfo =
CollaborationFactory.findSubjectInfo(objectStore, "bill", BaseObject.TYPE_USER, vwSession);
participantIdList.add(subjectInfo.getID());
subjectInfo =
CollaborationFactory.findSubjectInfo(objectStore, "betty", BaseObject.TYPE_USER, vwSession);
participantIdList.add(subjectInfo.getID());
pollInfo.setParticipants((String[])participantIdList.toArray(new String[0])); Date closingDateTime = new java.util.Date(currentDateTime.getTime() + 5000000 ); String question = "How many miles do you travel to work?"; String[] possibleResponses = {"Less than 5","5-14","15-39","40 or more"}; int priority = 3; //low level; 2 is normal, 3 high; boolean responsesHiddenFlag = true; // may be used as a "hint" if the need arises // to restrict display of results to the poll owner pollInfo.setClosingDateTime(closingDateTime); pollInfo.setQuestion(question); pollInfo.setPossibleResponses(possibleResponses); pollInfo.setResponsesHiddenFlag(responsesHiddenFlag); pollInfo.setPriority(priority); pollInfo.setParticipants(pollParticipantNames); pollInfo.setOwnerID(ownerID); // create a container for the poll and pass in the new PollInfo object to create the Poll ContainerManager containerManager = teamSpace.getContainerManager(); FolderContainer pollContainer = (FolderContainer) containerManager.getContainerByDefinitionID (Collaboration.COLLABORATION_POLL_CONTAINER_DEFID); Poll pollObject = pollContainer.addSubContainer(pollInfo);

Adding Poll Responses

Responses may be added immediately upon creation of a new poll. Participants respond through the Poll object's respond method:

    int responseIndex = 2; // select "15-39" in the zero-based possibleResponses list above
    String comment = "Not as far as traffic congestion makes it seem";
    pollObject.respond(memberID, responseIndex, comment);

Additional Information

For information on how polls are created and managed within the Team Collaboration Manager application, see Using Polls.