automated code-adding tool

charles.rooscharles.roos Member Posts: 60
Is there an automated tool that adds to several Navision objects at once some code? For example, i want to add to 50 table objects a new function, then is there a program that takes input those 50 objects exported into txt-format, and adds my function to all of those objects by pressing one button? I believe i such program is possible to do, and perhaps is done maybe, but i didn't find in google anything.

Comments

  • tinoruijstinoruijs Member Posts: 1,226
    I don't know if there's a tool, but it's very easy to copy a function within NAV. menu View, C/AL Globals, tab Functions, select function (blue line), then copy and paste it in other object where you need the function. All code and locals are being copied. :)

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • charles.rooscharles.roos Member Posts: 60
    tinoruijs wrote:
    I don't know if there's a tool, but it's very easy to copy a function within NAV. menu View, C/AL Globals, tab Functions, select function (blue line), then copy and paste it in other object where you need the function. All code and locals are being copied. :)

    But i don't want to copy-paste 50 times or more.
  • tinoruijstinoruijs Member Posts: 1,226
    tinoruijs wrote:
    I don't know if there's a tool, but it's very easy to copy a function within NAV. menu View, C/AL Globals, tab Functions, select function (blue line), then copy and paste it in other object where you need the function. All code and locals are being copied. :)

    But i don't want to copy-paste 50 times or more.

    I understand. But I think copying 50 times is faster than searching for a tool which probably, if there is one, has disadvantages and limits.
    But that's just my opinion. :)

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • DenSterDenSter Member Posts: 8,305
    But i don't want to copy-paste 50 times or more.
    It probably took longer to type this thread than it would take to copy a function into 50 tables.
  • charles.rooscharles.roos Member Posts: 60
    DenSter wrote:
    But i don't want to copy-paste 50 times or more.
    It probably took longer to type this thread than it would take to copy a function into 50 tables.

    But what if i need in the future to do such rutine again? There will be 10 such situations again? Can you do time calculations for that too?
  • tinoruijstinoruijs Member Posts: 1,226
    DenSter wrote:
    But i don't want to copy-paste 50 times or more.
    It probably took longer to type this thread than it would take to copy a function into 50 tables.

    But what if i need in the future to do such rutine again? There will be 10 such situations again? Can you do time calculations for that too?

    I think it should be an exeption to add the same function to 50 objects.
    It's much better to have 1 function in 1 place and call it from 50 different places.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • DenSterDenSter Member Posts: 8,305
    But what if i need in the future to do such rutine again? There will be 10 such situations again? Can you do time calculations for that too?
    I guess I just don't mind working at something. Things just take time. Developing a solution that would add functions to objects is possible, but would take MUCH more time than it would to copy a few functions over. So unless it is a regularly recurring task, it would just be much more efficient to just do the work and copy the function.
  • charles.rooscharles.roos Member Posts: 60
    tinoruijs wrote:
    DenSter wrote:
    But i don't want to copy-paste 50 times or more.
    It probably took longer to type this thread than it would take to copy a function into 50 tables.

    But what if i need in the future to do such rutine again? There will be 10 such situations again? Can you do time calculations for that too?

    I think it should be an exeption to add the same function to 50 objects.
    It's much better to have 1 function in 1 place and call it from 50 different places.

    I want to add such functionality that all matching (by name) fields is copied from any record to any record. For example:

    Customer.CopyMatchingFieldsTo(Contact1);
    Customer.CopyMatchingFieldsTo(Customer2);

    Those 2 functions would copy Name field value from Customer variable to Contact1 and Customer2 variable's Name field. How to achieve this? Also the reverse functionality is needed:

    Customer.CopyMatchingFieldsFrom(Contact1);
    Customer.CopyMatchingFieldsFrom(Customer2);

    This would copy matching fields from any record type to Customer record.

    I thought to add to Customer and other tables such function:

    "TransferFieldsToRecRef(VAR DestinationRecordRef : RecordRef)"

    This function would copy all matching (by name) fields from current table(Rec) object to the parameter, what-ever the type of the parameter is.

    The idea would be as:
    Customer.CopyMatchingFieldsTo(Contact1Ref);
    Contact1.CopyMatchingFieldsFrom(Contact1Ref);

    This would copy from Customer record the matching fields to Contact1 record.
    To achieve this i thought i should add those CopyTo and copyfrom functions to all tables so i can use them comfortably in the future for all tables. What do you think about this, maybe i have some bad strategy or something.
  • SavatageSavatage Member Posts: 7,142
    a bit off topic but perhaps Code Genius 2007 would be someting you like

    http://www.mibuso.com/dlinfo.asp?FileID=875
  • charles.rooscharles.roos Member Posts: 60
    Savatage wrote:
    a bit off topic but perhaps Code Genius 2007 would be someting you like

    http://www.mibuso.com/dlinfo.asp?FileID=875

    CodeGenius helps programming in a little way only, it doesn't help with adding into lot of objects the same/similiar code/function as i understand.
Sign In or Register to comment.