Can custom fields of type WebLink be queried?
search cancel

Can custom fields of type WebLink be queried?

book

Article ID: 57576

calendar_today

Updated On:

Products

Rally On-Premise Rally SaaS

Issue/Introduction

A user needs to query another system's defect ID in a CA Agile Central WebLink custom field but it is not working.

Cause

WebLink type custom fields is not queriable. This is the reason that all CA Agile Central connectors use String type of custom field and not WebLink type to reference an artifact in another system.

Below is a screenshot from WS API object model. It notes that "This attribute cannot be used in queries"

 

Resolution

Since it is not possible to query by WebLink any programmatic solution would involve querying artifacts by some other criteria, and later filtering the results as shown in this Ruby example based on CA Agile Central API Toolkit for Ruby.

require 'rally_api'

headers = RallyAPI::CustomHttpHeader.new()
headers.name = "Create stories and tasks"
headers.vendor = "RallyLab"
headers.version = "1.0"

config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:api_key] = "<API Key - include the underscore before the key>"  
config[:workspace] = "W1" 
config[:project] = "Team1"
config[:headers] = headers 
config[:version] = "v2.0"

@rally = RallyAPI::RallyRestJson.new(config)


workspace = "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/<WORKSPACE_OID>"
project = "https://rally1.rallydev.com/slm/webservice/v2.0/project/<PROJECT_OID>"

query = RallyAPI::RallyQuery.new()
query.type = "defect"
query.fetch = "Name,FormattedID,c_MyWebLink"
query.workspace = {"_ref" => workspace }
query.project = {"_ref" => project }
query.query_string = "(Tags.Name = \"tag1\")"
query.limit = 2 

results = @rally.find(query)

defects_with_empty_link = []
defects_with_link = []

results.each do |defect|
  puts defect.Name 
  defect.read    
  if defect.c_MyWebLink.LinkID.nil?
    defects_with_empty_link << defect
  else
    defects_with_link << defect
  end
end

puts "----------EMPTY WEB LINK----------"
defects_with_empty_link.each do |defect|
  puts "#{defect.FormattedID}, WebLink: #{defect.c_MyWebLink.LinkID}"
end

puts "---------WEB LINK-----------------"
defects_with_link.each do |defect|
  puts "#{defect.FormattedID}, WebLink: #{defect.c_MyWebLink.LinkID}"
end


NOTE: the code example is available as is. It is not supported by Rally.