Changing item status
The following example describes how to add a workflow event to an issue to change its status. The status is determined by the last event entered on an issue and is not directly entered by a user. You can perform similar steps to change the status of test cases, manual test runs, requirements, and requirement documents.
1. Localize external namespaces.
using System;
using System.Collections.Generic;
using System.Text;
2. Set up the namespace, provide the login information, and define the project name.
namespace DefectStatus
{
class DefectStatus
{
static void Main (string[] args)
{
long cookie = -1;
ttsoapcgi ttsdk = null;
try
{
string username = "username";
string password = "password";
string ProjectName = "ProjectName";
3. Create an instance of the ttsoapcgi class, which is generated from the ttsoapcgi.wsdl file.
ttsdk = new ttsoapcgi();
4. Set the URL that the ttsdk object connects to if you are not using the default URL from the WSDL file.
ttsdk.Url = "http://localhost:80/scripts/ttsoapcgi.exe";
5. Select the Helix ALM project to connect to and set proj to reference it.
CProject[] projects = ttsdk.getProjectList(username, password);
CProject proj = null;
foreach (CProject p in projects)
{
if (p.database.name.Equals(projectName))
{
proj = p;
break;
}
}
6. Log in to the project.
cookie = ttsdk.ProjectLogon(proj, username, password);
7. Use ttsoapcgi.editDefect() or ttsoapcgi.editDefectByRecordId() to retrieve and lock the record.
This prevents other clients or SOAP applications from editing the record. To search for an issue by summary, set the issue number to 0 and the summary to a non-empty string.
CDefect def = ttsdk.editDefect(cookie, 0, "Example Defect 1, With Formatted Text.", false);
8. Add an event to the issue.
The following example adds an event to an issue without any events.
def.eventlist = new CEvent[1];
CEvent evt = new CEvent();
def.eventlist[0] = evt;
9. Use the ttsoapcgi.getEventDefinitionList() to get information about the available events, including custom fields and resulting states.
evt.name = "Fix";
evt.user = "Lastname, Firstname MiddleInitial";
evt.notes = "This is the notes field, line one.\r\n" +
"This is the notes field, line two.";
evt.resultingstate = "Closed (Fixed)";
evt.fieldlist = new CField[5];
10. Populate the field list by creating instances of objects derived from CField.
Each field type contains different types of data, such as check box (Boolean) values, strings, and drop-down field values.
Note: Setting an object name allows Helix ALM to associate the data with the correct field.
CBooleanField AffectsDocs = new CBooleanField();
AffectsDocs.name = "Affects Documentation";
AffectsDocs.value = false;
evt.fieldlist[0] = AffectsDocs;
CBooleanField AffectTests = new CBooleanField();
AffectTests.name = "Affects Test Plan";
AffectTests.value = true;
evt.fieldlist[1] = AffectTests;
CDropdownField Resolution = new CDropdownField();
Resolution.name = "Resolution";
Resolution.value = "Code Change";
evt.fieldlist[2] = Resolution;
CDropdownField Version = new CDropdownField();
Version.name = "Version";
Version.value = "1.0";
evt.fieldlist[3] = Version;
CDecimalField RemTime = new CDecimalField();
RemTime.name = "Remaining Time";
RemTime.value = 2.5;
evt.fieldlist[4] = RemTime;
11. Save the changes.
ttsdk.saveDefect(cookie, def);
12. Finish editing the issue and catch exceptions.
Console.WriteLine ("Finished editing defect");
}
catch (Exception e)
{
Console.WriteLine("An exception occurred:");
Console.WriteLine(e.Message);
}
13. End the session and log out of the Helix ALM SDK.
finally
{
if (ttsdk != null && cookie != -1)
{
ttsdk.DatabaseLogoff(cookie);
}
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}

using System;
using System.Collections.Generic;
using System.Text;
namespace DefectStatus
{
class DefectStatus
{
static void Main(string[] args)
{
long cookie = -1;
ttsoapcgi ttsdk = null;
try
{
string username = "username";
string password = "password";
string ProjectName = "ProjectName";
ttsdk = new ttsoapcgi();
ttsdk.Url = "http://localhost:80/scripts/ttsoapcgi.exe";
CProject[] projects = ttsdk.getProjectList(username, password);
CProject proj = null;
foreach (CProject p in projects)
{
if (p.database.name.Equals(projectName))
{
proj = p;
break;
}
}
cookie = ttsdk.ProjectLogon(proj, username, password);
CDefect def = ttsdk.editDefect(cookie, 0, "Example Defect 1, With Formatted Text.", false);
def.eventlist = new CEvent[1];
CEvent evt = new CEvent();
def.eventlist[0] = evt;
evt.name = "Fix";
evt.user = "Lastname, Firstname MiddleInitial";
evt.notes = "This is the notes field, line one.\r\n" +
"This is the second line.";
evt.resultingstate = "Closed (Fixed)";
evt.fieldlist = new CField[5];
CBooleanField AffectsDocs = new CBooleanField();
AffectsDocs.name = "Affects Documentation";
AffectsDocs.value = false;
evt.fieldlist[0] = AffectsDocs;
CBooleanField AffectTests = new CBooleanField();
AffectTests.name = "Affects Test Plan";
AffectTests.value = true;
evt.fieldlist[1] = AffectTests;
CDropdownField Resolution = new CDropdownField();
Resolution.name = "Resolution";
Resolution.value = "Code Change";
evt.fieldlist[2] = Resolution;
CDropdownField Version = new CDropdownField();
Version.name = "Version";
Version.value = "1.0";
evt.fieldlist[3] = Version;
CDecimalField RemTime = new CDecimalField();
RemTime.name = "Remaining Time";
RemTime.value = 2.5;
evt.fieldlist[4] = RemTime;
ttsdk.saveDefect(cookie, def);
Console.WriteLine("Finished editing defect");
}
catch (Exception e)
{
Console.WriteLine("An exception occurred:");
Console.WriteLine(e.Message);
}
finally
{
if (ttsdk != null && cookie != -1)
{
ttsdk.DatabaseLogoff(cookie);
}
Console.WriteLine(Press any key to exit.");
Console.ReadKey();
}
}
}
}