NAV 2009 custom addin controls

kinekine Member Posts: 12,562
edited 2009-10-30 in NAV Tips & Tricks
NAV 2009 SP1 brings developers new possibility to extend RTC with own visual controls. Clear step by step description how you can create own addin is described in this Blog.

I recommend to read the article to know what is possible in the NAV 2009 SP1.
Kamil Sacek
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.

Comments

  • BeliasBelias Member Posts: 2,998
    This is really a step forward!Cool!
    RTC it's getting better and better...but it looks like I have to learn some C#...
    btw...nav is moving in this direction... :roll:

    *edit: i wonder if we will be able to implement something like an OnMousePos trigger...i have to read the post more carfully and wait for the real product to come out
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    You can fire one predefined event from the control with two parameters: one Integer and one String. There is trigger in NAV for this event. It means you can use this trigger as generic event of the control and use the integer to select what you want to fire in NAV etc.

    In some future versions there will be (may be) event support for the control (each event will have trigger in NAV), but not now...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    As I said, I have to read the blog more carefully (i couldn't understand your post, kine...), but what I meant (i didn't explained it because i was a bit in a hurry) was: implement some add-in that has an onmousepos, and then run C/al from that trigger (webservices, maybe?).
    Maybe i wrote some ridicolous things :oops: (i don't know C# and object oriented programming), i'll correct my post after investigating some more. Thanks for now
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    That's ok. What I wanted to wrote is, that in SP1 there is new trigger which can be fired from within the addin. This trigger you can fire on event in the addin you want (e.g. for OnMousePos). You can pass two parameters to this trigger - integer and text. It means you can use the same trigger in NAV for different events in addin and through index tell NAV which event it was etc... I hope that now it is more clear. Do not worry, all this is new for everyone and we all will need to learn something... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    Ok, more clear now: the "code flow" will then be something like:

    - An event triggers when using addin (to be simple: push a button in a winform)
    - The addin trigger calls the predefined C/al trigger passing a "developer-defined" ID in order to let nav know what add-in event is triggered(integer or text)
    - The C/al trigger execute some code

    But...can data be retrieved and or send to the add-in control? (maybe future blog posts will explain this... :-k )
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • dmccraedmccrae Member, Microsoft Employee Posts: 144
    Yes you can bind the data of the control to an AL Text or BigText variable and have it handled as a C# String or Object type in the control.
    Dean McCrae - Senior Software Developer, NAV Server & Tools

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • kinekine Member Posts: 12,562
    dmccrae wrote:
    Yes you can bind the data of the control to an AL Text or BigText variable and have it handled as a C# String or Object type in the control.

    Yes, but what about case when I have some customized edit box, it means the text to which it is bounded, is used as data, but I need to push some more data to the addin (not only the data string, but some settings or something like that)? Will it means that I need to envelop the data and settings into the string, pass it into the addin, and when saving, remove them and save only the plain data?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    kine wrote:
    You can fire one predefined event from the control with two parameters: one Integer and one String. There is trigger in NAV for this event. It means you can use this trigger as generic event of the control and use the integer to select what you want to fire in NAV etc.

    In some future versions there will be (may be) event support for the control (each event will have trigger in NAV), but not now...
    I just re-read the blog post and i was wondering...Can you kindly tell me where did you find these informations?(the nav trigger with integer and text)
    thanks!
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    It's fresh&new!! :mrgreen: Thank you!I'll take a look at it as soon as possible :wink:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • discovernetdiscovernet Member Posts: 1
    Thank a lot.
  • dmccraedmccrae Member, Microsoft Employee Posts: 144
    Kamil, yes it is currently limited in this respect. You need to construct your own data protocol to encapsulate the kind of additional data you're describing.
    Dean McCrae - Senior Software Developer, NAV Server & Tools

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • kinekine Member Posts: 12,562
    dmccrae wrote:
    Kamil, yes it is currently limited in this respect. You need to construct your own data protocol to encapsulate the kind of additional data you're describing.

    Ok, good to know. Do you think that there is some way around through using the functions in the dlls which are in the client folder? I can do databinding etc. with them... but I do not have enough knowledge about the model yet...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • dmccraedmccrae Member, Microsoft Employee Posts: 144
    That does not sound possible, because you will still need to communicate everything through the Client Extensibility provided interfaces.
    Dean McCrae - Senior Software Developer, NAV Server & Tools

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • BeliasBelias Member Posts: 2,998
    OK, now that we have the functionality in our hands, we should talk about it, i think...
    I tried to develop a simple add-in like the one descripted on msdn: http://msdn.microsoft.com/en-us/library/dd983804.aspx
    After 1h and a half i managed to get it work, but i have some questions:
    1. can i call methods of the add-in from C-al code?
    2. can i use add-ins on list pages?If yes, how?and why the descripted add-in does not work?
    3. can "onControladdin" trigger be fired from C/al? (i don't think so)
    4. consider this situation: I developed an add-in that must be used from every textbox in Nav and there's some code in the oncontroladdin trigger: Do I have to copy-paste the property and the code in each control?Or is there an Onglobalcontroladdin that can be overwritten?
    5. About the sample control add-in described in the link: how can i color the text?(this is a C# development question)
    6. What about future versions?I mean, is it useful to spend time with these add-ins or will them be replaced by something else? (e.g.: when C# development for nav will take effect)
    Thanks in advance
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    3. No, as any other automation events...
    4. I am afraid that you need to copy all what you need, there is no "global" way. Addin is there to replace some specific fields, not "change" the whole interface in general...
    5. I think it is Control.Font.Color
    6. They will not be replaced, they will be extended... :-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    kine wrote:
    3. No, as any other automation events...
    4. I am afraid that you need to copy all what you need, there is no "global" way. Addin is there to replace some specific fields, not "change" the whole interface in general...
    ...as i thought...btw, i have to admit it does make sense...
    kine wrote:
    5. I think it is Control.Font.Color
    No, it does not compile :-k (i already tried it, but simplicity is not part of C# :whistle: )
    kine wrote:
    6. They will not be replaced, they will be extended...
    perfect, i like them and it's a good variation of day2day work...if some customer will ever ask it :cry:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    5. Ok, than try "Control.ForeColor" (http://msdn.microsoft.com/en-us/library ... mbers.aspx)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    :thumbsup: it works, next step is to define the color for example like this
    customer name is blue if his balance is <0, otherwise it is yellow.

    (i know that there's a new property that support some formatting, but i'm here to learn add-ins)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • BeliasBelias Member Posts: 2,998
    oooooh...MouseHover!!!!!!!!it works!!
    think about a rec.DELETEALL run from mousehover of "customer name"...really bad joke to the customer!!(and to yourself) :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    Belias wrote:
    :thumbsup: it works, next step is to define the color for example like this
    customer name is blue if his balance is <0, otherwise it is yellow.

    (i know that there's a new property that support some formatting, but i'm here to learn add-ins)

    It is not easy to do that, because you need to pass the info through the text of the control, or use e.g. BigText as source expression for the control and fill it with all data which the addin needs and where it will return what you need... (you can pass whole XML file to the addin in this way - I recommend to look at this webcast if you are MS partner and you have access to trainings).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    Too bad...i hoped that there were something like a dataset of the page that could be accessed by the add-in (hope to be understood).
    In other words, kine, you're saying that now there's not an easy way to create add-ins which depends from the actual content of the page... :-k
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    Yes, it is not easy now. You need to pass the data through the control which is the source for the addin. But it could be done, in the webcast there is complex addin with some chart for customers you have filtered on the page, which is based on bigtext field, which is populated by the data for the filtered customers... and you can pass the changes through the bigtext back or through the event...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    A first use of custom add ins, which is nearly out of the box (for who do not know C# at all) is to call triggers that would instead be impossible to call in nav e.g. OnMousehover.
    The developer have to program just 20 lines of code in c# and he's done.
    Just follow http://msdn.microsoft.com/en-us/library/dd983804.aspx to create/register the dll (it was an hard work for me ](*,) ). Then delete the code in it and make something like this:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Dynamics.Framework.UI.Extensibility;
    using Microsoft.Dynamics.Framework.UI.Extensibility.WinForms;
    using System.Windows.Forms;
    using System.Drawing;
    
    
    namespace MyCompany.MyProduct.RtcAddins
    {
    
        [ControlAddInExport("MyCompany.MyProduct.FieldPopupAddin")]
        public class MyFieldPopupAddin : StringControlAddInBase
        {
            /// Defines the text box control.
            protected override Control CreateControl()
            {
                TextBox control = new TextBox();
                control.MouseHover += control_OnMouseHover;
                //ADD HERE MORE EVENTS WITH THE SAME SYNTAX
                return control;
            }
            /// Raises an event on Mouse Hover (this event does nothing except running the code in "OnControlAddIn" trigger).
            private void control_OnMouseHover(object sender, EventArgs e)
            {
                int index = 0;
                string data = this.Control.Text;
                this.RaiseControlAddInEvent(index, data);
            }
         }
    }
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Christian_AbelnChristian_Abeln Member, Microsoft Employee Posts: 42
    The main difference between COM and our Add-ins is:
    - COM is method / event oriented communication
    - Add-ins use a document based communication:
    + Bind the Add-in to data (simpple value or even XML through BigText / Blob binding
    + Add-in receives data through binding, can be asked to deliver changed data when saving and can initiate saving
    + Add-ins can fire one generic to trigger C/AL code (message id / text)

    It can be really harder to encapsulate a strong method / event oriented interfacing of COM objects into the document based communication. If you have control on the COM objects, it might be easier to rewrite those and replace the interfacing with a document based communication. (I have seen a case, where this document based communiation was even much better for the purpose of what those COM objects in this case were doing.)
    “This posting is provided "AS IS" with no warranties, and confers no rights.”

    Christian Abeln
    Program Manager Microsoft
    Dynamics NAV

    blogs.msdn.com/cabeln/
  • BeliasBelias Member Posts: 2,998
    what is the meaning of "document based communication" and "event based communication"?
    thanks in advance
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • BeliasBelias Member Posts: 2,998
    you can also automatically run reports from add-ins with this instruction...but i don't know if it useless, as you can do the same from nav in a simpler way...add this in the protected override Control CreateControl()
    System.Diagnostics.Process.Start("DynamicsNAV:////runreport?report=50000");
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • BeliasBelias Member Posts: 2,998
    does control add-ins works on lists? if so...how to make them work?i implemented a colored background in a card, but i can't implement the same add in on a list :-k
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    No, addins are not working within repeater...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.