Code highlighting

Wednesday, August 22, 2007

tutorial_Form_Dynalink (a small tutorial on dynalinks)

Today I was asked the following question:

"In dynamics we have a Form Named "Form1" I created a button on it "Button1".
It will manage all the records related to the key in main form. There is dyna link created between the datasources. Only records of the currently selected main Key field will be shown. I need the selected KeyField value on the other form. How can I get it?"


So I wrote a small project to show the different possibilities.
In the project you will find 2 forms, 2 tables and a menuItem connecting the two forms.
3 ways of getting the current dynalink value are shown.

Here is a link to the xpo with the project:
download

Here is a screenshot of the result:



Forgot to give some explanations as well: :)
Basically, all the 3 form methods showing different ways of getting the dynalink value are called from the linkActive method in the second (slave) form.
This method is activated by the system every time a record in the parent form is changed, which allows for dynalinks to work. Great method :)

2 comments:

  1. very useful example! thank you!

    just in case if somebody like me wants to clear Dynalinks between two forms I might suggest to add in Init() on DataSource of the second form after method Super() the following:

    if (element.args() && element.args().record() && element.args().record().tableId == tableNum(YourTable1))
    {
    CurrentTable_ds.query().dataSourceNo(1).clearDynalinks();
    }

    ReplyDelete

Please don't forget to leave your contact details if you expect a reply from me. Thank you