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

Having trouble populating Push dialog dropdown list


#1

I’m building a TFS defect plugin. I need to have a dropdown list with the iterations from TFS. I am able to retrieve the iterations from TFS and build an array but when I send the array to the dropdown list I get this error.

htmlspecialchars() expects parameter 1 to be string, object given

My “_build_iteration_tree” function looks just like one for OnTime_REST.

private function _build_iteration_tree(&$result, $iteration, $level)
{
foreach ($iteration as $iter)
{
$p = obj::create();
$p->id = $result[$level]->id.’\’.’\’.$iter->{‘name’};
$p->name = $result[$level]->name.’\’.’\’.$iter->{‘name’};

		$result[] = $p;
							
		if ($iter->{'hasChildren'})
		{
			$this->_build_iteration_tree($result, $iter->children, $level + 1);
		}
	}
}

#2

Hi John,

It looks like you are somewhere passing back an array instead of a string which TestRail expects. Please make sure you understand and follow the documentation for writing a custom defect plugin, especially the workflow and form handling of prepare_push and prepare_field:

http://docs.gurock.com/testrail-integration/defects-plugins-custom#pushing_defects_with_a_dialog

Cheers,
Tobias


#3

Tobias,

I got it to work. I went back and looked how the Jira_REST plugin worked and I found out that there was a function that converted the object array into a string array.

private function _to_id_name_lookup($items)
{
$result = array();
foreach ($items as $item)
{
$result[$item->id] = $item->name;
}
return $result;
}

I added that to my code and it worked.

Thanks,
John


#4

Thanks for the update, John, great to hear it works now!

Cheers,
Tobias