Options

NAV Classic 2009 R2 - Case statements

Morning.

I am having to write case statements to pick out the country code and match it to the Country name. Tested it before I finished putting in the 80+ lines and It is just picking up the first case. It treats all customers as if it had GB. I inserted a test phraze in the first line - instead of blank I put "This is broken!" and when i ran the report it showed This is Broken on every address. Also I swapped the GB line for the SE line and ran it again to find out every address had Sweden on it.

I am obviously missing something but cannot see it. Can someone point me in the right direction?


Customer - OnAfterGetRecord()
CountryName :='Failure of address';

CASE "Country/Region Code" OF

("Country/Region Code"),'GB':CountryName :='';

("Country/Region Code"),'SE':CountryName :='SWEDEN';

("Country/Region Code"),'AE':CountryName :='United Arab Emirates';

("Country/Region Code"),'AR':CountryName :='Argentina';




ELSE

CountryName :='Not Working';
END

Best Answers

Answers

  • Options
    vaprogvaprog Member Posts: 1,118
    edited 2017-08-14
    Is this C/AL? It likely won't even compile! Check the syntax.
  • Options
    jonesksjonesks Member Posts: 29
    Yes it is C/AL and I am very new to it! It is compiling though. I know it must be the syntax but I cannot for the life of me work out what I have done wrong!
  • Options
    jonesksjonesks Member Posts: 29
    Yes, just discovered that! When I said new to NAV - I mean two weeks! I realise what I did with the case statements now someone has pointed it out to me!
    Now all I need to do is work out how to look up use table nine to give me the country name!
    Thanks!
    As Richard Branson said - if someone gives you a fantastic opportunity that you are not sure you can do, say yes and learn to do it later! (In my case thats on the job!)
  • Options
    jonesksjonesks Member Posts: 29
    Ok - I know I can do this with about two lines of code - but I just cannot work it out! Any clues would be appreciated!
    Thanks in advance!
  • Options
    DenSterDenSter Member Posts: 8,304
    edited 2017-08-16
    Not sure what you want there. You asked a question and you marked two replies as the answer. If there is something else you need help with, the best thing to do is create a new topic.
  • Options
    jonesksjonesks Member Posts: 29
    Sorry for the confusion - The first answer works - it solves the problem I was having with the syntax I then realised that there must be an easy way to do it and the second answer is the easy way to do what I was wanting so both answers are very good and both work!
  • Options
    jonesksjonesks Member Posts: 29
    Yes - I had gone mentally blind! First time I have worked in C/AL and haven't done any coding for ten years. As soon as I saw AK's answer I kicked myself!
Sign In or Register to comment.