Skip to main content
Participant
Aug 8, 2023 4:55 PM UTC
Answered

Can I add Metadata via Python API?

Hello! 

I want to save some information I create via python to a new metadata property. Is this possible? 

I can see it's possible using pysbs, but I assume that's for when I don't have designer open already, can I use pysbs functions inside designer? 

 

Thanks!

This topic is closed to new replies. Start a new post to keep the conversation going.
Reuben5C64Correct answer
Inspiring
Aug 8, 2023 7:50 PM UTC

if you have a package object, you can do something like this:

metadata = package.getMetadataDict()
metadata.setPropertyValueFromId("key", SDValueString.sNew("value"))

 I don't see the sd api reference online, but from Designer if you click "Help"->"Scripting Documentation", you should be able to find what you're looking for in the API to create and retrieve metadata

 

 

2 replies

Reuben5C64Correct answer
Inspiring
Aug 8, 2023 7:50 PM UTC

if you have a package object, you can do something like this:

metadata = package.getMetadataDict()
metadata.setPropertyValueFromId("key", SDValueString.sNew("value"))

 I don't see the sd api reference online, but from Designer if you click "Help"->"Scripting Documentation", you should be able to find what you're looking for in the API to create and retrieve metadata

 

 

Translate
mo42Author
Participant
Aug 17, 2023 8:09 AM UTC

Amazing, this is exactly what I was hoping for, thank you so much! 
I had assumed the key needed to exist before I could use setPropertyValueFromId, but you don't! 

Thanks again! 🙂 

Translate