How to read and set CustomAttributes through macro?

  • 2
  • Question
  • Updated 5 years ago
  • Answered
I am using mindjet 14. I'd like to read and set the CustomAttributes value through macro.
But Topic.Attributes(Namespace) needs a namespace. How can I know what the namespace for certain topic object should be?
Photo of Jimmy

Jimmy

  • 14 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 2
Photo of Nigel Goult (Olympic & MIVAP)

Nigel Goult (Olympic & MIVAP)

  • 348 Posts
  • 134 Reply Likes
Jimmy are you talking about data held in the custom properties of a Topic?

If so:

Topic.DataContainer.CustomProperties.GetCustomPropertyValue("CustomPropertyName")

should give you the Value of "CustomPropertyName".

If you are talking about Custom Attributes that you create then you decide the namespace when you add the attribute:

Topic.Attributes("yourNamespace").SetAttributeValue("attributeName","attributeValue")

You then use the same "yourNamespace" when referencing the attribute.

Hope this helps

Nigel

Olympic Limited Mindjet Solution Specialists
Photo of Jimmy

Jimmy

  • 14 Posts
  • 0 Reply Likes
Thanks Olympic for your reply.
I still do not get my answer. I want to know how to get or set an customed attributes value by macro.
Please let me make it clear step by step:
1. Firstly I made an customed attribute by "Tag" pop up menu, for example: a tag group 'Status' has a tag "Completed".
2. I assigned this tag to a topic.
3. I want to get or set this tag's value by macro. When I run t.Attributes("yourNamespace").GetAttributeValue("Status") , it returns "" (empty). But it should return "Completed".
So my questions are:
1. When I made a tag manually, the namespace of this tag is "yourNamespace" automaticelly?
2. If not, then what should this namespace be?
Please check the attachment picture for my questions. Thanks
Photo of Jimmy

Jimmy

  • 14 Posts
  • 0 Reply Likes
By the way, how can I get or set the resource for a topic by Macro? Thanks!
Photo of Nigel Goult (Olympic & MIVAP)

Nigel Goult (Olympic & MIVAP)

  • 348 Posts
  • 134 Reply Likes
Jimmy,

Ah, the reason you are confused is you are talking about two different objects.

CustomAttributes are not what you are trying to access. You are trying to access the Topic Tags object which in the object model are actually named "TextLabels".

The object is "TextLabel"
The collection is "TextLabels"

Look at these and I am sure you will see what you need.

Regarding resources, these you can set using "Topic.Task.Resources("yourResource")

Nigel

Olympic Limited Mindjet Solution Specialists
Photo of Jimmy

Jimmy

  • 14 Posts
  • 0 Reply Likes
Thanks for you reply very much!
I can get and set the tag value now based on your advice!
But I cannot set Resource. Please see the picture:



What's more, when a topic synced with outlook, then Topic.Task.ResourcesReadonly becomes True automaticelly. How can I own the Outlook Sync function and Resources in the same time?
Photo of Nigel Goult (Olympic & MIVAP)

Nigel Goult (Olympic & MIVAP)

  • 347 Posts
  • 133 Reply Likes
Jimmy, apologies I made a mistake.

It should be:

Topic.Task.Resources = "yourResoureName"

Hope that helps.

Re: the Outlook question I am afraid I do not know.
Photo of Jimmy

Jimmy

  • 14 Posts
  • 0 Reply Likes
Thank very much!
All of the problem are dealed!