cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fill metaAttribute dynalically like 'MessageFlow'(Metaclass) Local name

Frequent Contributor

Fill metaAttribute dynalically like 'MessageFlow'(Metaclass) Local name

Hello All,

 

Can anyone suggest :

How to fill the metaattribute dynamically.

(For example, 'MessageFlow' object Local name - Source --> Target))

 

I have a new metaclass for which I am able to create a 'Local name'(MetaAttribute) of the object dynamically.
But, I am unable to fill it same like MessageFlow Local name.

 

I am using AttCtl_SetText function in MetaAttributeUpdateTool macro.

 

But this is getting fired everytime when I open 'Properties' of the object. This should not happen.
Function should trigger only for the first time of the object creation not always opening properties.

 

Am I using correct function/macro ? ?

 

Thanks in advance,

Kartik
from
Colruyt

Colruyt Team
5 Replies
MEGA

Re: Fill metaAttribute dynalically like 'MessageFlow'(Metaclass) Local name

Hello,

 

if you want a computed value for a metaAttribute, you need to

1 - Set the "_AtNature" property of  your metaAttribute to "Virtual"

2 - On your metaAttribute : "right click > New > Macro"

3 - In the macro, use the "getAttributeValue" Sub (the "Value" parameter of this sub will be the displayed value in your metaAttribute)

 

Regards

 

Lionel

Frequent Contributor

Re: Fill metaAttribute dynalically like 'MessageFlow'(Metaclass) Local name

Hello Lionel,

 

Thanks for the reply.

 

I am trying to create a dynamic message.
So, unless the object is created I cannot create  a message.

Eg: Source --> Target

 

From GetAttributeValue I think we can only get static message.

 

See below code:

Sub GetAttributeValue(Object as MegaObject,AttributeID as Variant,Value as ByRef)

 

Value = Object.getCollection("Source  Flow Element").item(1).getProp("Name") & "-->" & Object.getCollection("Target Flow Element").item(1).getProp("Name")

 

End sub

 

When I execute this, I get Empty object invocation error.
Which is expected because 'Object' is not created yet here.

Thats the reason, I tried with AttCtrl_SetText function of Metaattribute updateTool macro.

 

Waiting for your reply.

Thanks,
Kartik

Colruyt Team
MEGA

Re: Fill metaAttribute dynalically like 'MessageFlow'(Metaclass) Local name

Hello Kartik,

 

why don't you just "test" the existence of your source and target element ?

 

Sub GetAttributeValue(Object as MegaObject,AttributeID as Variant,Value as ByRef)
  Dim SourceObject, TargetObject
  Value = ""
  Set SourceObject = object.getCollection("Source Flow Element").Item(1)
  Set TargetObject = object.getCollection("Target Flow Element").Item(1)
  If SourceObject.getId <> 0 AND TargetObject.getId <> 0  Then
    Value = SourceObject.Shortname & "-->" & TargetObject.ShortName
  End If 
End sub

Lionel

 

 

Frequent Contributor

Re: Fill metaAttribute dynalically like 'MessageFlow'(Metaclass) Local name

Hello Lionel,

 

Thanks for your reply. 

 

I can test but my requirement is to fill the attribute with source and target mandatorily.

 

A 'Flow' cannot exist without 'Source' and 'Target'. So when I do Object--rightClick--Properties I need to see Source-->Target message.

 

Thanks,
Kartik

Colruyt Team
Frequent Contributor

Re: Fill metaAttribute dynalically like 'MessageFlow'(Metaclass) Local name

Can someone help me for this requirement.

 

Thanks in advance,
Kartik

Colruyt Team