19-11-2012 05:57 PM
Hello,
at the moment i am trying to update an attribute via an attached Macro. i am referencing to the same attribute in the code to be able to change the Generic Local Name afterwards. The situation is as follows: 2 attributes, "Geschäftsprozess-ID" and "Geschäftsprozess-Name" are changeable via Property Page. After someone updates one of those attributes, the Generic local name should be updated with the new values. Generic local Name is set together by "Geschäftsprozess-ID" and "Geschäftsprozess-Name".
This is the macro code:
'MegaContext(Fields,Types)
'To Implement if you want to have a computed value for this attribute
Sub GetAttributeValue(Object as MegaObject,AttributeID as Variant,Value as String)
End Sub
'To Implement instead of GetAttributeValue if you want to manage a specific display or extended value
'Format : 0 internal, 1 external, 3 Display, 5 externalCode
Sub GetExtendedAttributeValue(Format as Integer,Object as MegaObject,AttributeID as Variant,Value as String)
temp1 = Object.getAttribute("Geschäftsprozess-ID").Value("Display")
temp2 = Object.getAttribute("Geschäftsprozess-Name").Value("Display")
Object.getAttribute("Generic Local Name").Value = temp1 & "." & temp2
End Sub
'To Implement if you want to overload the update of this attribute
Sub SetAttributeValue(Object as MegaObject,AttributeID as Variant,Value as String)
End Sub
'To Implement instead of SetAttributeValue if you want to manage a specific display or extended value
'Format : 0 internal, 1 external, 3 Display, 5 externalCode
Sub SetExtendedAttributeValue(Format as Integer,Object as MegaObject,AttributeID as Variant,Value as String)
End Sub
'To Implement for a Text attribute to fix the text format of the given text
Sub GetTextFormat(Object as MegaObject,AttributeID as Variant,Value as Variant)
End Sub
If i try to attach the macro for example to "Geschäftsprozess-Name", i get two errors.
Exception in 3fc Dispatch Macro Invoking Geschäftsprozess-Name.Macro.GetExtendedAttributeValue GetProp : Undocumented Error(0x800a001c) (Script Geschäftsprozess-Name.Macro.GetExtendedAttributeValue)
Script error "Error(0x80020009) : Already reported Error(0x80020101) (Script Geschäftsprozess-Name.Macro.GetExtendedAttributeValue)" at Line 11 : Geschäftsprozess-Name.Macro : GetProp
i already found out that
temp2 = Object.getAttribute("Geschäftsprozess-Name").Value("Display")is my problem.
I assume the reason is that i am referencing to the attribute in the attribute update code, so it's like a deadlock?Is there any other way to find out the value of the attribute?
Thanks in advance for your help.
Tobias
Solved! Go to Solution.
05-11-2019 08:43 PM - edited 05-11-2019 08:43 PM
@lionel , just wanted to say thank you for your post and solution....
7 years later, it is as useful !
21-11-2012 03:05 PM
Hello Tobias,
you have 3 major problems in your code
1 - Your defaultkind should be "ComboBox" as your macro concerns a tabulated metaAttribute.
2 - You forgot to give a value to strTMP
3 - You have to use the "external" value of your metaAttribute.
In the end, your code should look like this :
'MegaContext(Fields,Types)
'Uses(Components)
'Option Explicit
Function AttCtl_GetDefaultKind() As String
AttCtl_GetDefaultKind = "ComboBox" 'First modification
End Function
Function AttCtl_Update(Context As MegaUpdateToolContext, Status, ErrorMessage) As Boolean
Dim strTMP
Dim myProcess
Set myProcess = Context.MegaObject
strTMP = Context.EditText 'Second modification
Set colComp1 = myProcess.getCollection("Komponente") 'It is better to use a "Set"...
For each itemComp1 in colComp1
itemComp1.setProp "Prozesslandkarte-Bereich", strTMP, "External" 'Third modification
colComp2 = itemComp1.getCollection("Komponente")
For each itemComp2 in colComp2
itemComp2.setProp "Prozesslandkarte-Bereich", strTMP, "External" 'Idem
colComp3 = itemComp3.getCollection("Komponente")
For each itemComp3 in colComp3
itemComp3.setProp "Prozesslandkarte-Bereich", strTMP, "External" 'Idem
colComp4 = itemComp3.getCollection("Komponente")
For each itemComp4 in colComp4
itemComp4.setProp "Prozesslandkarte-Bereich", strTMP, "External" 'Idem
colComp5 = itemComp4.getCollection("Komponente")
For each itemComp5 in colComp5
itemComp5.setProp "Prozesslandkarte-Bereich", strTMP, "External" 'Idem
Next
Next
Next
Next
Next
End Function
One last thing : except if you have thousands of processus, in which case requests could be very long, there is no use to explicitely go down five levels. If I were you, I would do it this way :
'MegaContext(Fields,Types)
'Uses(Components)
Function AttCtl_GetDefaultKind() As String
AttCtl_GetDefaultKind = "ComboBox"
End Function
Function AttCtl_Update(Context As MegaUpdateToolContext, Status, ErrorMessage) As Boolean
Dim strTMP
Dim myProcess
Set myProcess = Context.MegaObject
strTMP = Context.EditText 'Second modification
Set colComp1 = Context.MegaObject.GetRoot.GetSelection("Select ~pj)grmQ9pG90[Processus métier] Where ~5l)gvmQ9p8E0[Composé] Deeply """ & myProcess.getProp("~210000000900[Nom]") & """")
For each itemComp1 in colComp1
itemComp1.setProp "Prozesslandkarte-Bereich", strTMP, "External"
Next
End Function
21-11-2012 01:19 PM
Hello lionel
thanks for your help, it worked.
I am running in another question with those attribute updates, perhaps you can also help.
Assume i have Processes on 5 Levels over Aggregate / Component Relationships. Now i have an attribute "Prozesslandkarte-Bereich" with 3 Enumerations in a dropdown - "Kern-Prozess", "Steuerungs-Prozess", "Support-Prozess".
Now i would like to edit this attribute on Level 1 and the selected value should be handed down to all Processes connected via "Component" Association. I tried this with something similar to your solution:
'MegaContext(Fields,Types)
'Uses(Components)
'Option Explicit
Function AttCtl_GetDefaultKind() As String
AttCtl_GetDefaultKind = "Edit"
End Function
Function AttCtl_Update(Context As MegaUpdateToolContext,Status As Integer,ErrorMessage As String) As Boolean
Dim strTMP
Dim myProcess
Set myProcess = Context.MegaObject
colComp1 = myProcess.getCollection("Komponente")
for each itemComp1 in colComp1
itemComp1.setProp "Prozesslandkarte-Bereich",strTMP
colComp2 = itemComp1.getCollection("Komponente")
for each itemComp2 in colComp2
itemComp2.setProp "Prozesslandkarte-Bereich",strTMP
colComp3 = itemComp3.getCollection("Komponente")
for each itemComp3 in colComp3
itemComp3.setProp "Prozesslandkarte-Bereich",strTMP
colComp4 = itemComp3.getCollection("Komponente")
for each itemComp4 in colComp4
itemComp4.setProp "Prozesslandkarte-Bereich",strTMP
colComp5 = itemComp4.getCollection("Komponente")
for each itemComp5 in colComp5
itemComp5.setProp "Prozesslandkarte-Bereich",strTMP
next
next
next
next
next
End Function
if i attach this to the MetaAttribute, the dropdown gets lost.
For all other Levels the attribute is read-only. I already managed to do this via Metatest & Condition in the Property Page configuration.
Can you or someone else help me with this problem?
Thanks
Tobias
21-11-2012 10:17 AM
Hello Tobias,
I had quite a hard time trying to understand what you wanted to do.
In short, you have 2 specific MetaAttributes and when one of these is modified, you want the name of your process to be modified (the new name being the concatenation of the two attributes)
First of all, at least one of these two attributes should have it's _AtIndex at "Unique" (if not, you will have to manage the fact that 2 processes may have the same name...) :
Then, since you want the name of your process to be updated each time one of these 2 metaAttributes is modified, you must create 2 macros (one for each metaAttributes) linked to the metaAttributes by the MetaAttributeUpdateTool link.
Example for the Geschäftsprozess-ID attribute :
Then, you have to code your macro this way :
'MegaContext(Fields,Types)
'Uses(Components)
Option Explicit
Function AttCtl_GetDefaultKind() As String
AttCtl_GetDefaultKind = "Edit"
End Function
Function AttCtl_Update(Context As MegaUpdateToolContext,Status As Integer,ErrorMessage As String) As Boolean
Dim strTMP
Dim myProcess
strTMP = Context.EditText 'This correspond to the attribute you are modifying
Set myProcess = Context.MegaObject
If Trim(strTMP) <> "" Then 'The name will be modified only if the "unique" attribute is not empty
myProcess.SetProp "nom court", strTMP & myProcess.getProp("Geschäftsprozess-Name")
End If
End Function
Create the same macro for your "Geschäftsprozess-Name" attribute :
'MegaContext(Fields,Types)
'Uses(Components)
Option Explicit
Function AttCtl_GetDefaultKind() As String
AttCtl_GetDefaultKind = "Edit"
End Function
Function AttCtl_Update(Context As MegaUpdateToolContext,Status As Integer,ErrorMessage As String) As Boolean
Dim strTMP
Dim myProcess
strTMP = Context.EditText 'This correspond to the attribute you are modifying
Set myProcess = Context.MegaObject
If Trim(myProcess.getProp("Geschäftsprozess-ID")) <> "" Then 'The "unique" attribute must not be empty
myProcess.SetProp "nom court", myProcess.getProp("Geschäftsprozess-ID") & strTmp
End If
End Function
Well, I hope that helps 🙂
Lionel