Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

Not able to access custom field value

#1

Hi All,

i am using test rail using selenium and when i am trying to read the value of a custom field called as External ID , it returns me null. Could you help me.

External ID system name is externalid

JSONObject c = (JSONObject) client.sendGet(“get_case/1”);
System.out.println(c.get(“title”));
System.out.println(c.get(“externalid”));

0 Likes

#2

Hi there,

Thanks for the post! When accessing custom field data through the API you’ll need to add the prefix custom_ to the defined system name used when creating the field. In your case, you should set it up using custom_externalid.

Hope that helps!

0 Likes

#3

Hi @jacob.scott . Thanks for the reply. I tried it but it is not working. I created a new field and gave system name as shown below in yellow (custom_automationid)

when i run the code it gives me null.

JSONObject c = (JSONObject) client.sendGet(“get_case/1”);
System.out.println(c.get(“title”));
System.out.println(c.get(“custom_automationid”));

0 Likes

#4

Instead of get_case . we have to use get_case_fields like below , but there is a value which i have provided for this field , how do i access that value. ?

JSONArray c = (JSONArray) client.sendGet(“get_case_fields/1”);
System.out.println(c.size());
System.out.println(c.get(5));

0 Likes

#5

I got the answer. Thanks a lot. “get_tests” is another API method that needs to used

0 Likes

#6

@jacob.scott Also Explicitly we do not have to write custom for custom fields. For all custom fields custom is prefixed with them . so if you prefix a custom field name with custom_ , then it will become custom_custom_fieldname.

0 Likes

#7

Hi Vinu,

Apologies for the confusion! I worded that poorly I realize now, what I meant to say is that TestRail automatically adds the custom_ prefix, so when referring to those fields using the API, you would need to include it before the system name you defined. Thank you for the response and for clarifying the point.

0 Likes