Options

ChangeComany Function doesn't support Validate function?

ShonatinaShonatina Member Posts: 114
Hi Experts,

I would like to know why the validate function isn't supported in the changecompany function and what can be used instead of validate function.

Thanks.
smile always
shona
That which you seek inside is that which you find outside

Comments

  • Options
    jglathejglathe Member Posts: 639
    Hi Shonatina,

    ... because it was designed this way. :( The root node of the context is company, representing approx. the same as a company code in SAP (for instance). Transactions outside a company are possible, but more like an afterthought than by design. The context of your transactions (and for all variables within) is set by opening up a session in the specified company. Therefore, all validates and views are in this context. When you do a changecompany() on a table, the context for the TableData object changes, but not for the variables inside the record - meaning all validates work, but refer to the original session context.
    In NAV2013 you can start separate background sessions with an entry point (codeunit) and a context (company). I think it will be a big improvement for cross-company transactions, but wouldn't solve the functionality problem many actual NAV users have. They have grown over time and are larger structures now, with several companies (split for legal or technical reasons). This brings master data management issues, and intercompany transactions.

    HTH.

    with best regards

    Jens
  • Options
    gerrykistlergerrykistler Member Posts: 149
    You basically have to take the code within the OnValidate function into what ever code you have written and mirror that code with whatever variables you need and call the CHANGECOMPANY on all those record variables as well.

    I have been frustrated by this for years and am looking forward to 2013, for at least some ability to do this.
    Gerry Kistler
    KCP Consultores
  • Options
    DenSterDenSter Member Posts: 8,304
    The change in 2013 isn't in CHANGECOMPANY, but you can actually program C/AL to start a new session in another company, which is actually much better. You can just spin off another session and tell that session what to do, and you can continue on in your own session, very powerful stuff. Might be a good idea for a blog :mrgreen:
Sign In or Register to comment.