Unable to get data into .Net Add-in Navision 2013

oxilleryoxillery Member Posts: 7
edited 2013-05-31 in NAV Three Tier
Hi

I made a RichTextBox add-in to use in NAV 2013. I already tested this in the NAV 2009 R2 and it worked fine.

So what I did:
- Compile and sign the add-in
- Copy to Add-ins folder of NAV 7

- Register the add-in to the "Client Add-in" table (2000000069)

Then I created a table to store my notes called: "Contact Notes" where my data from my add-in will be stored in the field Content as a BLOB:


After that I made a CardPart:


Here I linked the Add-in to the Content field:


I add this cardPart to "My Customer Card" and set the relation so when you go to the next customer you corresponding note is opened.


Here is the code that is written in my add-in:
    [ControlAddInExport("Astena.RichTextboxEditor")]
    public class RichTextBoxAddin: WinFormsControlAddInBase, IObjectControlAddInDefinition
    {        
        public NavPanel Panel;

        private bool Loaded = false;

        protected override Control CreateControl()
        {            
            Debug.WriteLine("CreateControl(): Control Loading");
            Panel = new NavPanel();
            return Panel;
        }

         public bool HasValueChanged
        {
            get
            {
                Debug.WriteLine("Get: HasValueChanged = "+Panel.EditorChanged); //Debug
                return Panel.EditorChanged;
            }
        }

        public object Value
        {
            get
            {
                Debug.WriteLine("Get: Value"); //Debug
                Debug.WriteLine(Panel.EditorValue);
                
                Debug.WriteLine("Get: Value: Reset Loaded bool");//debug
                Loaded = false;
                Debug.WriteLine("Get: Reset HasChanged");
                Panel.ResetEditorChanged();
                return Encoding.UTF8.GetBytes(Panel.EditorValue);
            }
            set
            {
                Debug.WriteLine("Set: Start"); //Debug
                byte[] data = (byte[])value;

                string input = "";
                if(data != null) input = Encoding.UTF8.GetString(data);

                Debug.WriteLine("Input.Legth: "+input.Length);
                Debug.WriteLine("Set: Value - Input:");
                Debug.WriteLine(input);

                if (data != null && !Loaded)
                {
                    Debug.WriteLine("Set: Value - Data != null && !Loaded"); //Debug

                    //Debug.WriteLine("Set: Value - Input:");//Debug
                    //Debug.WriteLine(input);//Debug

                    if (input.Length > 75) //min rtf text length is 119 (including the headers)
                    {
                        Debug.WriteLine("Set: Value - Input.Length > 75");
                        Panel.EditorValue = Encoding.UTF8.GetString(data);
                        Loaded = true; //only here is valuable data loaded
                    }
                    else
                    {
                        Debug.WriteLine("Set: Value - Input.Length > 75");
                        Panel.EditorValue = "";
                    }
                    
                }
                Debug.WriteLine("Loaded: "+Loaded);
            }
        } 

        public event ControlAddInEventHandler ControlAddIn;
    }

If I type some text in my textbox it will get stored in the database. I Checked this by looking in the table through MSSQL. I also checked the length of the byte array that was stored.
The problem I'm having is that when I open the page again, or move to another customer and then return, The previous stored data isn't returned. When I debug on the Set property it gets an array of length 8 and if you convert this to string it will be a square.

I have no idea what causes this problem or if I'm doing something wrong.

Thanks in advance
Oxillery

Comments

  • kinekine Member Posts: 12,562
    Are you doing CALCFIELDS on the BLOB field before it is passed into the addin?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • oxilleryoxillery Member Posts: 7
    No I'm not doing a CALCFIELDS. Is that nessecary? Because I don't have any codeunit that handles the data or interacts whit the add-in.
    The interface "IObjectControlAddInDefinition" should normally handle the data.

    Is the way that BLOB data is handled changed in 2013?

    EDIT: I took a closer look to the used code in the 2009 R2 and noticed that at some point a calcfields is used. I think you might be wright about the calcfields.
  • DidimitchDidimitch Member Posts: 6
    Hello,

    I have the exact same situation here.
    Everything was OK on 2009R2 and now not working anymore with 2013.
    In fact I can enter data and see that it is stored corectly by using Jet Report to access it. But when I try to read and display it on textBox add-in, i get a special character and then 7 squares instead of the proper text...

    Any ideas ?

    Thanks.
  • absolutelyfreewebabsolutelyfreeweb Member Posts: 104
    Hi, I have the exact same problem.
    But I also think that what we store is different.
    Using the same object, saving the same text, what I see in sql in the blob is different for R2 and 2013.

    Desperately need help!
  • deV.chdeV.ch Member Posts: 543
    Blobs changes form 2009 to 2013, blobs are compressed by default and the compression method was a legacy nav method in <=2009, but now changed to .net Deflate method. Therefore the content is not the same. If a calcfields does not the trick, you could try to deflate the byte array by yourself? Maybe this helps. Here is an example of this: http://devch.wordpress.com/2013/01/17/accessing-compressed-blobs-from-outside-nav-nav2013/
Sign In or Register to comment.