Applies to QAComplete 12.20 SaaS, last modified on June 17, 2019

The code below shows how to link a defect in your project to another item (a release). The code uses the TraceabilityLinks_Add operation to add a traceability link to the defect.

You can link items of any other type the same way you link a defect and a release. The EntityCode, FKId, LinkedEntityCode, and LinkedFKId properties of the traceability link specify the items you want to link.

C#

string login = "john.doe@example.com";
string password = "p@ssword";
int projID = 10372;

// Specifying the first item
string entityCode = "Bugs";
int FKId = 35;

// Specifying the second item
string linkedEntityCode = "Releases";
int linkedFKId = 23;

// Specifying the type of the link
string linkType = "Found in build";

ServiceSoapClient service = new ServiceSoapClient();

// Preparing AuthenticationData
LoginInfo loginInfo = service.GetLoginInfo("", login, password);
AuthenticationData authData = new AuthenticationData();
authData.AppCode = loginInfo.AppCode;
authData.UserId = loginInfo.UserId;
authData.PassCode = password;
authData.DeptId = loginInfo.DeptId;
authData.ProjId = projID;

// Preparing the TraceabilityLink object
TraceabilityLink link = new TraceabilityLink();
link.EntityCode = entityCode;
link.FKId = FKId;
link.LinkedEntityCode = linkedEntityCode;
link.LinkedFKId = linkedFKId;
link.LinkType = linkType;
            
// Adding a link between two items
int linkId = service.TraceabilityLinks_Add(authData, link);
Console.WriteLine("Created link: {0}", linkId);

Java

String login = "john.doe@example.com";
String password = "p@ssword";
int projId = 10372;

// Specifying the first item
String entityCode = "Bugs";
int FKId = 35;

// Specifying the second item
String linkedEntityCode = "Releases";
int linkedFKId = 23;

// Specifying type of the link
String linkType = "Found in build";

ServiceSoap service = new Service().getServiceSoap12();

// Preparing AuthenticationData
LoginInfo loginInfo = service.getLoginInfo("", login, password);
AuthenticationData authData = new AuthenticationData();
authData.setAppCode(loginInfo.getAppCode());
authData.setUserId(loginInfo.getUserId());
authData.setPassCode(password);
authData.setDeptId(loginInfo.getDeptId());
authData.setProjId(loginInfo.getProjId());

// Preparing the TraceabilityLink object
TraceabilityLink link = new TraceabilityLink();
link.setEntityCode(entityCode);
link.setFKId(FKId);
link.setLinkedEntityCode(linkedEntityCode);
link.setLinkedFKId(linkedFKId);
link.setLinkType(linkType);

// Adding a link between two items
int linkId = service.traceabilityLinksAdd(authData, link);
System.out.println("Created link: " + linkId);

To learn more about the TraceabilityLinks_Add operation syntax, parameters and view sample request and response, see the operation description.

See Also

TraceabilityLinks_Add Operation
How To Add Items
How To

Highlight search results