This article describes how to create issues using the SystemWeaver API.


To be able to do this, you will first need to obtain the project Handle. The easiest way to do this is to configure a report for the project using the swExplorer client.


Enter a report name in the New Issue Report dialog.


Add the following definition to the New Report Definition dialog: 

<Report>

<Text>#{Handle}</Text>

</Report>


Click on Report to obtain the Handle that you will need. 

Example

string projectHandle = "x26000000000128E9";
IswItem item = SWConnection.Instance.Broker.GetItem(SWHandleUtility.ToHandle(TextBoxId.Text));
IswProject project = SWConnection.Instance.Broker.GetProject(SWHandleUtility.ToHandle(projectHandle));

IswIssueTypes issueTypes = project.Definition.IssueTypes;

// Get relevant issueType. In this case we just pick the first one.
IswIssueType type = issueTypes[0];

// Create issue
IswIssue newIssue = project.AddIssue(type, "AName");

// To set the status, Get the issue workflow.
IswWorkflow workFlow = newIssue.swIssueType.Workflow;

// Select a status and assign it to the issue.
IswWorkflowStatuses statuses = workFlow.Statuses;
newIssue.Status = statuses[0];

// Add a reference, the SID IR is the default issue relation.
newIssue.AddObjRef("IR", item);