cancel
Showing results for 
Search instead for 
Did you mean: 

Diagram API Message Flow Creation

SOLVED
Highlighted
Frequent Contributor

Diagram API Message Flow Creation

Hi Community,

Can anyone give the sample code for creating a message flow between two business processes on a diagram through the diagram API.

 

Iam bit confused by looking at the API documentation.

 

Thanks in advance.

Colruyt Team
4 REPLIES
MEGA

Re: Diagram API Message Flow Creation

Hi,

 

First you need to create the message flow and connect the sender and receiver using the standard MEGA API.

Then add the message flow to the diagram by calling the "megaobjectinsert" method on the drawing object (the sender and receiver must be in the diagram already).

This method returns a DrawingItem object that you can use to position the object nicely in your drawing.

 

 

Set myFlow = getcollection("message flow").create
myflow.getcollection("Source Element").add getobjectfromid("~16ixex(JNzp5[Management System] ")
myflow.getCollection("Target Element").add getobjectfromid("~Azr9AZ2KN5X6[Customer] ")

Set mydiagram = getobjectfromid("~v5oxSz(JNH0T[Application Environment Diagram] ")
set mydrawing = mydiagram.drawing("RW")
Set flowdrawingitem = mydrawing.megaobjectinsert(myflow)

'removing all points except both ends to make the line straight
set parentdrawingitem = flowdrawingitem.ItemProperty("ParentDrawingItem")
set flowpoints = parentdrawingitem.ItemProperty("DrwLine_Points")
For i = 1 to flowpoints.count - 2
    flowpoints.removepoint(1)
Next
parentdrawingitem.ItemProperty("DrwLine_Points") = flowpoints

mydrawing.flush
mydiagram.open

 

Gregory

Frequent Contributor

Re: Diagram API Message Flow Creation

Thanks Gregory. It worked for me Smiley Happy .

Colruyt Team
Frequent Contributor

Re: Diagram API Message Flow Creation

hi,

Can you please tell me How I can set customized line style and Draw Line Points to the newely created object.

I already have a link on diagram. I need to draw the new line just on the same points.

 

How can I get the draw line points og old link, and how I can draw new line on same points.

 

Set oLineStyle = oDrawingItem.LineStyle   //get old line style

parentdrawingitem.LineStyle = oLineStyle     //set style to new line

parentdrawingitem.ItemProperty("DrwLine_Points") = oDrawingItem.ItemProperty("DrwLine_Points")  //assign draw line points

 

 

The above code is not working for me.

 

Thanks in advance.

 

Colruyt Team
Frequent Contributor

Re: Diagram API Message Flow Creation

Hi Gregory,

This is regarding the solution you've given me for message flow creation:

 

http://community.mega.com/t5/Technical-Product/Diagram-API-Message-Flow-Creation/m-p/12717#M2458

 

Am trying to insert message flow twice on the diagram (which is possible from V1R3 cp13 on Application environment diagram)

 

//this part is working fine am able to see the link on diagram

Set flowdrawingitem1 = mydrawing.megaobjectinsert(myflow)
set parentdrawingitem1 = flowdrawingitem1.ItemProperty("ParentDrawingItem")

 

//This part is not working the parent drawing item is null here

Set flowdrawingitem2 = mydrawing.megaobjectinsert(myflow)
set parentdrawingitem2 = flowdrawingitem2.ItemProperty("ParentDrawingItem")

 

how I can I place a message flow object twice on diagram

 

Can you please help me to fix this.

 

Colruyt Team