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

Not able to import custom fields


I have added many custom fields for my requirement

socialview - String
socialcomponent - String
socialsubcomponent - String

other fields like

socialview - Dropdown
socialautomated - Dropdown

I am able to import only string but not dropdown from import xml though I am able dropdown values in xml created using csv2testrail script

Below is the filter I am using, Can you please check and reply if there is any limit is number of columns or what is this issue ?

<?php /** * Copyright 2010 Gurock Software GmbH. All rights reserved. * [url][/url] - */ function custom_filter($csv) { // Skip the first line unset($csv[0]); // Iterate rows and build cases foreach ($csv as $row) { // Create a new case and assign the various properties $case = array(); //$case['title'] = $row[0]; $case['title'] = $row[0]; $case['type'] = $row[1]; $case['priority'] = $row[2]; $case['socialautomationid'] = $row[9]; $case['socialbrowserspecific'] = $row[10]; $case['socialautomated'] = $row[11]; $case['socialregression'] = $row[12]; $case['socialinternationalisation'] = $row[13]; // Custom fields, such as Preconditions, Steps and // Expected Results $custom = array(); $custom['preconds'] = $row[3]; $custom['steps'] = $row[4]; $custom['expected'] = $row[5]; $custom['socialview'] = $row[6]; $custom['socialcomponent'] = $row[7]; $custom['socialsubcomponent'] = $row[8]; $case['custom'] = $custom; // The export script will automatically create the section // hierarchy for us. All we have to do is to specify the // sections for a test case in this format: // // "Section 1 > Section 2 > Section 3" //$case['section'] = $row[6]; // Add the cases to the list $cases[] = $case; } // Return all cases return $cases; } ?>


Also what is the difference between case and custom in above code ?


Hello Chandan,

Thanks for your posting. For dropdown fields, you need to specify the ID of the dropdown value as part of an block. Specifically, this would look like this in the XML file:

<custom> .. <my_field> <id>2</id> </my_field> .. </custom>

To assign a value in the custom filter routine so that the migration script outputs the above markup, please specify it like this:

Regarding the difference between “case” and “custom”: system fields belong to the $case object/array (e.g. title, priority, etc.) and custom fields should be part of $custom.

I hope this helps and please let me know in case you have any further questions!