Scripting - Get default provider from a specific project

Is there a way to get the default provider of a project.

I want to be abale to get the provider for a specific project then export it to json file.

There might be a better way to do this I'm not thinking of, but one option would be to rely on the script context threadlocal:

This will obviously only work in scenarios where we actually know the project and therefore default provider to provide it before your script runs.

What I want is to get the default provider name configured in a specific project, I want to be able to do an system.tag.exportTags(tagPaths = [default provider]) and I only know the project name.

No easy way to do that, unfortunately. You'd have to retrieve the 'GlobalProps' resource per-project and look inside it for the default datasource.

'GlobalProps' is a built-in object accessible by a function or it's thru the system files?

GlobalProps is a class that holds...global props :smile:
https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.27/com/inductiveautomation/ignition/common/project/GlobalProps.html

You obtain an instance of the class by deserializing the project resource, e.g. with ResourceUtil:
https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.27/com/inductiveautomation/ignition/common/util/ResourceUtil.html

You obtain a ProjectResource from the project system; how you do that depends on what scope you're calling this from. Ignition Extensions can help with that.

I figure better your comment "No easy way to do that, unfortunately."

If you have a script example it will help me, i'm not so familiary by using class

Is there an easy way to get the project title ?

From a gateway context (search the forum) you can retrieve the project manager.
From the project manager, you can call getProject(name) which returns an Optional<Project> ; so you'd use a snippet like: context.projectManager.getProject(name).get() to receive an unwrapped RuntimeProject.
RuntimeProject has a getManifest() method, and the ProjectManifest has a getTitle() method.

1 Like