Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Pass field/attributes values from java codes to RTC using JAZZ API's

 

I am trying to create work item in RTC through java application using the jazz api's.

My connection to the repository is successful. Now i need to set all the required fields through java code in order to save/run the workitem. Really dont know how to set those values in below codes.

   String repositoryURI= args[0];
        String userId= args[1];
        String password= args[2];
        String projectAreaName= args[3];
        String typeIdentifier= args[4];
        String summary= args[5];
        String categoryName= args[6];

        ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
        teamRepository.registerLoginHandler(new LoginHandler(userId, password));
        teamRepository.login(null);

        IProcessClientService processClient= (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);
        IAuditableClient auditableClient= (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);
        IWorkItemClient workItemClient= (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);

        URI uri= URI.create(projectAreaName.replaceAll(" ", "%20"));
        IProjectAreaHandle projectArea= (IProjectAreaHandle) processClient.findProcessArea(uri, null, null);
        //IProjectAreaHandle projectArea = teamArea.getProjectArea();
        if (projectArea == null) {
            System.out.println("Project area not found.");
            return false;
        }
        //IWorkItemType workItemType = service.findWorkItemType(projectArea, "defect", monitor);
        IWorkItemType workItemType= workItemClient.findWorkItemType((IProjectAreaHandle) projectArea, typeIdentifier, null);
              //  findWorkItemType(projectArea, typeIdentifier, null);
        if (workItemType == null) {
            System.out.println("Work item type not found.");
            return false;
        }
        System.out.println("Category not found.: " + categoryName );

        List path= Arrays.asList(categoryName.split("/"));

        System.out.println("Category not found.: " + path );
        ICategoryHandle category= workItemClient.findCategoryByNamePath((IProjectAreaHandle) projectArea, path, null);
        //ICategoryHandle category= 
        if (category == null) {
            System.out.println("Category not found.: " + category );
            return false;
        }


        WorkItemInitialization operation= new WorkItemInitialization(summary, category);


        IWorkItemHandle handle= operation.run(workItemType, null);

        IWorkItem workItem= auditableClient.resolveAuditable(handle, IWorkItem.FULL_PROFILE, null);

        System.out.println("Created work item " + workItem.getId() + ".");

        teamRepository.logout();
						

While running the codes i am receiving the below errors. Because of mandatory fields are not assigned. Can any one help me to pass the attribute values (Contact Phone) from java to jazz. ERROR received:

Severity: ERROR Summary: Attribute 'Contact Phone #' not set Description: The 'Contact Phone #' attribute needs to be set (work item <09:13:03>).

1

0 votes



One answer

Permanent link
It is quite obvious from the error message, that you have to either remove required attributes or set the attributes that are required. For the latter the only guidance we can give is

https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/
https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/

0 votes

Comments

Thanks for the answer, I cannot remove the required attributes and i have to set these values in java codes. Can you suggest me how to find the attribute id for the field and pass some values foe the same,
Thanks for your time.

All these questions are answered in the blog posts mentioned above, which are actually created to help new users of the API to get the basic understanding needed and an introduction to the most important API's. Of course that requires they actually bother with reading them if hinted to. You are searching for

workItem.getCustomAttributes();
or you look up the attribute ID in the process configuration (in the Web UI).






Given solution works perfectly for the textbox, however i cannot pass the field values  for the attribute which has dropdown box. (for example, I need to select the first value from the options). Please help me to sort out this issue.


Thanks for your valuable time.

I have provided the basic links you need. you can copy text over fine, but you will have to map other values such as enumerations as mentioned in the posts and here: https://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/

Good luck.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 6,117
× 1,699

Question asked: Jul 14 '16, 1:53 p.m.

Question was seen: 3,331 times

Last updated: Jul 15 '16, 7:12 a.m.

Confirmation Cancel Confirm