[Feature-12077]Project Script to Get Project Names

I’m looking to replicate this script from 7.9.10 to 8.0. The script first gets the project names for all the projects on the ignition server and then writes the dataset tag to a memory tag. I am trying to do the same with 8.0 but am having trouble writing the dataset information to the memory tag as my script is not writing to my memory tag. I appreciate the help.

The script for 7.9 is:

def getProjectNames():
	from com.inductiveautomation.ignition.gateway import SRContext
	from com.inductiveautomation.ignition.common.project import ProjectVersion
	projects = SRContext.get().getProjectManager().getProjectsLite(ProjectVersion.Published)
	return system.dataset.toDataSet(['Projects'], [[project.getName()] for project in projects])

def getProjectInfo():
	from com.inductiveautomation.ignition.gateway import SRContext
	from com.inductiveautomation.ignition.common.project import ProjectVersion
	
	projects = SRContext.get().getProjectManager().getProjectsLite(ProjectVersion.Staging)

	headers = [
		'Name', 
	]

	info = [
		[
		project.getName(), 
		] 
		for project in projects
	]
	return system.dataset.toDataSet(headers, info)

Then on another tag I am running the script:

projects = shared.Projects.getProjectInfo()
system.tag.write("[.]Projects",projects)

For 8.0 I am running the following script:

def getProjectNames():
	from com.inductiveautomation.ignition.gateway import IgnitionGateway
	return system.dataset.toDataSet(['Projects'], [[name] for name in IgnitionGateway.get().getProjectManager().getProjectNames()])

def getProjectInfo():
	from com.inductiveautomation.ignition.gateway import IgnitionGateway
	
	headers = [
		'Name'	
	]
	
	info = [
		[
		IgnitionGateway.get().getProjectManager().getProjectNames(),
		]
		for project in projects
	]
	
	return system.dataset.toDataSet(headers, info)

Then on a seperate tag I am running:

projects = shared.Projects.getProjectInfo()
system.tag.write("[ . ]Projects", projects)

Please edit your post to use a code block (so we can read it). Place three backquotes (these ```) on a line above your code, and again on a line below your code.

I have updated my post above.

If you can wait a few weeks, there’s going to be a system.project.getProjectNames() function within the next release or two.

2 Likes

system.project.getProjectNames() just got merged in and will be in 8.0.11.

1 Like