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

Trigger.ui: How to get run id dynamically in UI script?


Example code provided is using “” to get run id. However this is not triggering the php script. When run_id is hard coded we are able to trigger (url: “”) php script.

What is the way to get run id dynamically in UI script?


Hello Ashweeja,

Thanks for your posting. is the right way to get the current run ID but this is only available on the actual test run page (not on the plan page, for example). Can you post the full example? Maybe there’s something wrong with how is accessed or formatted as URL parameter.



Hi Tobias,

Thanks for your reply. I’m actually using it from test run page. Below is the UI script I’m using. Could you let me know if I’m missing anything?

name: Trigger tests for run
description: Triggers automated tests for a test run
author: Gurock Software
version: 1.0
includes: ^runs/view

(document).ready( function() { /* Create the button */ var button = (‘

Start Tests
	/* Add it to the toolbar */
	$("#content-header .content-header-inner").prepend(button);		

	/* Bind the click event to trigger the automated tests */
	$("a", button).click(
				/*url: "" +,*/
				url: "",
				dataType: "json",
				type: "GET",
				success: function()
				error: function()
						'An error occurred while trying to trigger the automated tests.'

				'The tests are being processed in the background and the results are automatically posted back to TestRail. This page refreshes once the tests are finished.',
			return false;



I would recommend using your web browser’s debugging tools to see which request is sent, and which response is received. Please note that the trigger script is only a starting point and you would need to adjust it for your needs. That said, in general we wouldn’t recommend using the trigger approach, as it doesn’t add a lot of benefits. We would usually recommend simply triggering your tests outside of TestRail (e.g. via your CI system) and then using TestRail’s API to submit the test results to TestRail:

I hope this helps!


Thanks for reply. That really helped me to resolve the issue.

I have modified trigger script according to my needs. Only problem I had is to initiate it with correct run id.


That’s great to hear, Ashweeja, and thanks for the update :slight_smile: