NewBugData.SetField Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The NewBugData.SetField method sets a new value for a Jira field.

Declaration

NewBugData.SetField(Name, Value)

Name [in]    Required    String    
Value [in]    Required    String    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Name

The name of the Jira field the value will be set for.

To set values for Jira custom fields, use their identifiers instead of the field names.

Value

The new value for the specified Jira field.

Result Value

None.

Remarks

You can use the SetFieldJSON method to set field values as well.

Example

The code below demonstrates how you can use SetField method in your script tests:

JavaScript, JScript

function BugToJira()
{
  // Log in to Jira
  Jira.Login("https://mycompany.atlassian/net/", "[email protected]", "c40Mwj3PovmRTFZbmIiwB8C2");
  // Create an object that defines bug properties
  var jiraData = Jira.CreateNewBugData("MyJiraProjectKey", "John Smith", "High", "Sample bug summary", "Sample bug description").
                setField("customfield_10700", "12.40.08");
  // Post the issue to Jira
  var key = Jira.PostIssue(jiraData);
  // Attach the desired file to the created issue
  Jira.PostAttachment(key, "C:\\temp\\MyFile.txt");
}

Python

def BugToJira():
  # Log in to Jira
  Jira.Login("https://mycompany.atlassian/net/", "[email protected]", "c40Mwj3PovmRTFZbmIiwB8C2")
  # Create an object that defines bug properties
  jiraData = Jira.CreateNewBugData("MyJiraProjectKey", "John Smith", "High", "This is a sample bug summary", "Sample bug description").\
                setField("customfield_10700", "12.40.08");
  # Post the issue to Jira 
  key = Jira.PostIssue(jiraData)
  # Attach the desired file to the created issue
  Jira.PostAttachment(key, "C:\\temp\\MyFile.txt")

VBScript

Sub BugToJira
  ' Log in to Jira
  Call Jira.Login("https://mycompany.atlassian/net/", "[email protected]", "c40Mwj3PovmRTFZbmIiwB8C2")
  ' Create an object that defines bug properties
  Set jiraData = Jira.CreateNewBugData("MyJiraProjectKey", "John Smith", "High", "Sample bug summary", "Sample bug description")._
                setField("customfield_10700", "12.40.08")
  ' Post the issue to Jira
  key = Jira.PostIssue(jiraData)
  ' Attach the desired file to the created issue
  Call Jira.PostAttachment(key, "C:\\temp\\MyFile.txt")
End Sub

DelphiScript

procedure BugToJira;
var 
  jiraData, key;
begin
  // Log in to Jira
  Jira.Login('https://mycompany.atlassian/net/', '[email protected]', 'c40Mwj3PovmRTFZbmIiwB8C2');
  // Create an object that defines bug properties
  jiraData := Jira.CreateNewBugData('MyJiraProjectKey', 'John Smith', 'High', 'This is a sample bug summary', 'Sample bug description').
                setField('customfield_10700', '12.40.08');
  // Post the issue to Jira
  key := Jira.PostIssue(jiraData);
  // Attach the desired file to the created issue
  Jira.PostAttachment(key, 'C:\temp\MyFile.txt');
end;

C++Script, C#Script

function BugToJira()
{
  // Log in to Jira
  Jira["Login"]("https://mycompany.atlassian/net/", "[email protected]", "c40Mwj3PovmRTFZbmIiwB8C2");
  // Create an object that defines bug properties
  var jiraData = Jira["CreateNewBugData"]("MyJiraProjectKey", "John Smith", "High", "This is a sample bug summary", "Sample bug description")
                ["setField"]("customfield_10700", "12.40.08");
  // Post the issue to Jira
  var key = Jira["PostIssue"](jiraData);
  // Attach the desired file to the created issue
  Jira["PostAttachment"](key, "C:\\temp\\MyFile.txt");
}

To interact with Jira custom fields, use their identifiers instead of the field names. In the code above, it is customfield_10700.

To call this function from keyword tests, use the Run Code Snippet operation.

See Also

NewIssueData Object

Highlight search results