Comparing Option integer values

davidecdavidec Member Posts: 63
Hello!

I'm using NAV 4.0, SP1 and I have to change a report, to include only some lines which meet certain conditions. I'm working in the OnAfterGetRecord() trigger and I'm having problems with one of the rules I have to check.

I have to check the "G/L Account"."Account Type" field, in order to determine if the current record is Begin-Total. The application language is set to Italian, but I need the report to work even if the language were English, so I thought I could compare the "Account Type" integer value: how can I do that? :shock: Or is there a better/simpler solution to my problem?

You've probably guessed I'm a newbie and you're right, so please, if you know how to do that, could you add some code, please?

Thank you very much for your help!

Comments

  • BeliasBelias Member Posts: 2,998
    IF "account type" = "account type"::"0" then begin
    

    i wrote "0" for the first option, you can sure use the other options :mrgreen::mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • rocatisrocatis Member Posts: 163
    Internally, Navision operates with option values as integers.

    "Account Type"::"Begin-Total" is actually represented as "Account Type"::"0" internally - you can also write it like that when coding, it will automatically be converted into the corresponding OptionString text.

    What this means is that if you change the OptionString for the field it will automatically change in your code as well.

    Navision will always use the OptionString to represent the option value, never OptionCaption or OptionCaptionML. Therefore you'll have no problems dealing with different languages.
    Brian Rocatis
    Senior NAV Developer
    Elbek & Vejrup
  • davidecdavidec Member Posts: 63
    WOW GRAZIE Mille!

    Thank you very much, it worked... :D
    I didn't know operator ::
  • BeliasBelias Member Posts: 2,998
    read carefully rocatis post, too(he explains the logic, too)...things to know about options fields are not only '::' operator...

    also you will note that after saving the object, if you review your code, the number you wrote as the option, is automatically transfomed in the correspondent value in the option string... :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    Belias wrote:
    read carefully rocatis post, too(he explains the logic, too)...things to know about options fields are not only '::' operator...

    also you will note that after saving the object, if you review your code, the number you wrote as the option, is automatically transfomed in the correspondent value in the option string... :mrgreen:

    And same thing work for REPORT::"125" and FORM::"123" and DATABASE::"123"... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jlandeenjlandeen Member Posts: 524
    that's a cool little trick. I didn't know it worked for the Navision objects as well...but I guess it makes sense!
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • ayhan06ayhan06 Member Posts: 210
    jlandeen wrote:
    that's a cool little trick. I didn't know it worked for the Navision objects as well...but I guess it makes sense!

    one more trick: you dont need to write all option string.
    "G/L Account"."Account Type"::"B" also works :mrgreen:
  • jlandeenjlandeen Member Posts: 524
    Yes I've used it when dereferencing option values of a field before...just not those internal Nav objects (like form, report, etc.).

    However one thing about your example:
    "G/L Account"."Account Type"::"B" also works

    Note that if there are multiple option values with 'B' as the starting character it will pick the first one (I've had that bite me in the ass before) - so you have to make sure that you type enough of the word that there is only one choice for the compiler to make.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • krikikriki Member, Moderator Posts: 9,115
    kine wrote:
    Belias wrote:
    read carefully rocatis post, too(he explains the logic, too)...things to know about options fields are not only '::' operator...

    also you will note that after saving the object, if you review your code, the number you wrote as the option, is automatically transfomed in the correspondent value in the option string... :mrgreen:

    And same thing work for REPORT::"125" and FORM::"123" and DATABASE::"123"... ;-)
    And also this works : recSalesHeader."3" for field "No." in table "Sales Header".
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.