Options

Importing custom codeunit: Overwriting issues

DnealDneal Member Posts: 103
Hi,

Here's an interesting issue I have recently run into. Hoping someone out there can shed some light on it.

I'm using Navision 4.0. I added a custom table and a custom form which creates functionality to produce a cover letter report. I utilized the codeunit Transfer Extended Text(378). I added custom functions to CU 378 to make it work, and it does.

So we have an add-on which allows a window to appear and word wrap comments for the client. This add-on also added custom functions to CU 378.

When I imported the add-on codeunit for the word wrap, the functions within this add-on codeunit contains calls to the Transfer Extended Text codeunit (378). It should be using it's own created functions in 378(I manually integrated), but instead the calls have been replaced with my custom functions in CU378. This is difficult for me to try and explain, so I'll try a short form:

378 - Transfer Extended Text - CodeUnit - Manually add functions for the word wrap. ie..InsertWordWraptoSalesLine

14005080 - Word Wrap - CodeUnit - Gets imported in.

When I look a the Word Wrap codeunit instead of it's original call:

TransferExtendedText.InsertWordWraptoSalesLine

It says TransferExtendedText.InsertCoverLetterLines (Which is my custom function in TransferExtendedText)

I don't understand how this happens. I have tried different orders to which I import the CU's. When I think it's working, my custom subform for the cover letter gets altered. Instead of calling TransferExtendedText.InsertCoverLetterLines it uses TransferExtendedText.InsertWordWraptoSalesLine.

No where in the import worksheet does it list the custom cover letter subform change. I found this while debugging.

I have got it to work, by manually testing everything. But when the time comes to import this to a clients live database, it will have to all be carefully integrated and some things will always have to manually be changed. Not to mention the fact that it all seems very unstable and a little unpredictable, who know what else got altered.

Any ideas why this happens?
Dneal

Comments

  • Options
    kinekine Member Posts: 12,562
    The functions are identified by their ID Nos. It seems, that the imported object (14005080) is using his own function in CU 378 with some ID. But instead this function you created your own function but with same ID (ID are assigned in same way as IDs for controls etc.). Change ID on your function (Show Globals - Functions - Properties) - may be that both functions have same ID... :-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    DenSterDenSter Member Posts: 8,304
    And next time you integrate your solution, you should start with adding the functions, and then add the function calls to the other objects.
  • Options
    DnealDneal Member Posts: 103
    Thank you for that explanation. It always helps to know what the application is doing and how it works internally.
    And next time you integrate your solution, you should start with adding the functions, and then add the function calls to the other objects.

    If this the case, then I have to remove all my preexisting customized function calls every time I add new functions to a codeunit. Is there no way around this?

    DNeal
  • Options
    DenSterDenSter Member Posts: 8,304
    It hardly every happens that when you add the function that it creates an ID that already exists in there. You have to be aware of it though.

    You don't have to remove anything. Here's how I do it:
    I have my source database open in one window, and the target database in another. I also have a code compare tool (I use Beyond Compare) open to compare the objects. If I see that the object in my target is missing a function, I open the source database and copy the function (open the globals, go to your functions tab, select the function and hit Ctrl+C), and paste it into the target database (open the same object, go to the functions tab in the globals and hit CTRL+V). The compiler should tell you if there's anything wrong.

    If you run into the same issue every time you merge, you just have to renumber the functions in your source database and you should be set.
  • Options
    DnealDneal Member Posts: 103
    Thanks again for the explanation. I am curious as to how I would renumber the functions in my source database.

    Dneal
  • Options
    DnealDneal Member Posts: 103
    Nevermind, I found it in the properties of the function. :)
  • Options
    DenSterDenSter Member Posts: 8,304
    Yep that's where you do it. It's a good tip to try to open the properties window everywhere you go, just to see where you can set any of them. I am still surprised at what is available sometimes.
Sign In or Register to comment.