Jump to content

Closing a session in Javascript API


Recommended Posts

  • 2 months later...
On 5/22/2018 at 3:29 AM, Mattias Lagergren said:

I'm afraid there is no equivalent to what we have in the ftrack-python-api. How are you using the ftrack-javascript-api, are you building a custom widget?

Not exactly.

I'm calling the API from the main HTML document of an Adobe CEP panel (https://github.com/Adobe-CEP/Getting-Started-guides) in almost exactly the way it's called in this example in the FTrack documentation: http://ftrack-javascript-api.rtd.ftrack.com/en/stable/tutorial.html. With the goal of getting data from a users Tasks and displaying it in a <div>.

It's extremely simple, here's a rough breakdown of the html:

<!doctype html>
		<meta charset="utf-8">
			<!-- Ftrack API -->
			<script src="./lib/ftrack.min.js"></script>
				<button id="loadFTrackStuff" onclick="getTaskList()">Load Tasks</button>
			<div id="taskList"></div>
		function getTaskList() {

			document.getElementById("taskList").innerHTML = '';

			var session = new ftrack.Session(

			session.initializing.then(function () {
				var request = session.query('select name, type.name, custom_attributes, incoming_links, outgoing_links, priority.name from Task where status.name is "Ready To Start" and assignments any (resource.username = "john.doe@example.com")');
				request.then(function (response) {
					var taskData = response.data;
					var tdl = taskData.length;
					for (var i = 0; i < tdl; i++) {
						document.getElementById("taskList").innerHTML += "<div>" + taskData[i].name + ",  <b>Type:</b>" + taskData[i].type.name + ",  <b>Priority:</b>" + taskData[i].priority.name + '</div><div>(' + (taskData[i].incoming_links.length+taskData[i].outgoing_links.length) +  "Links) " + (taskData[i].custom_attributes[0].key + ":" + taskData[i].custom_attributes[0].value) + " " + (taskData[i].custom_attributes[3].key + ":" + taskData[i].custom_attributes[3].value) + "</div>";


Everything works fine, I was just curious if this sort of use is problematic if the session(s) are never closed explicitly.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...