why primary key is blank

vyankuvyanku Member Posts: 791
In some tables like Company Information,Gen. Ledger setup the primary key these tables is blank.
Why it is always blank?

Comments

  • BeliasBelias Member Posts: 2,998
    edited 2007-11-19
    usually in tables like this, you would insert only one record: inserting the record with a blank primary key, allows you to use
    "TBCompanyInfo.GET" instruction without arguments for the "get" function.
    I'm pretty sure that the use is this
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • azerty74azerty74 Member Posts: 82
    Yes, in a setup table the key is always left blank, because there can only be 1 record in a setup table.
    Debugging is twice as hard as writing code. Therefore if you write the code as cleverly as possible you are by definition not smart enough to debug it.
  • krikikriki Member, Moderator Posts: 9,110
    azerty74 wrote:
    Yes, in a setup table the key is always left blank, because there can only be 1 record in a setup table.
    Or better : there SHOULD only be 1 record in a setup table.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ssinglassingla Member Posts: 2,973
    wonder how this is handled in other products like AX, GP, Solomon, SAP, Oracle
    CA Sandeep Singla
    http://ssdynamics.co.in
  • Alex_ChowAlex_Chow Member Posts: 5,063
    kriki wrote:
    azerty74 wrote:
    Yes, in a setup table the key is always left blank, because there can only be 1 record in a setup table.
    Or better : there SHOULD only be 1 record in a setup table.

    Have you tried to insert another records into the setup table? Does the SetupTable.GET still work if there are more than one record?
  • kinekine Member Posts: 12,562
    Yes, it works until there is one record with blank PK. If there is no record with blank PK, it will show you standard error.

    Someone is using more records e.g. in Company Info table to store adresses and data for different offices and it is easy to modify the reports to get the correct address - just instead .GET you use .GET(MyOfficeCode) and you are done...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • krikikriki Member, Moderator Posts: 9,110
    kine wrote:
    Someone is using more records e.g. in Company Info table to store adresses and data for different offices and it is easy to modify the reports to get the correct address - just instead .GET you use .GET(MyOfficeCode) and you are done...
    I've seen the same use of the company info table.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Alex_ChowAlex_Chow Member Posts: 5,063
    This means you don't need to do any modifications to store different company logo for one company?

    Just use companyinfo.GET if you want to use the standard logo. And use companyinfo.get('1') if you want logo for another company.
  • ssinglassingla Member Posts: 2,973
    This means you don't need to do any modifications to store different company logo for one company?

    Just use companyinfo.GET if you want to use the standard logo. And use companyinfo.get('1') if you want logo for another company.

    Interesting Observation............ :whistle: :whistle:
    CA Sandeep Singla
    http://ssdynamics.co.in
  • girish.joshigirish.joshi Member Posts: 407
    Indeed, good idea, Alex!
  • kinekine Member Posts: 12,562
    Alex Chow wrote:
    This means you don't need to do any modifications to store different company logo for one company?

    Just use companyinfo.GET if you want to use the standard logo. And use companyinfo.get('1') if you want logo for another company.

    Yes, for example. You just need to add the Primary key to the form and fill it by some code. Than you can store that code into some setup, to not use "Magic constants" in the code and you are done...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Alex_ChowAlex_Chow Member Posts: 5,063
    So the next time when someone posts how to get 2 different logos in the same company, just refer them to this post. :D
  • tihomirjurtihomirjur Member Posts: 21
    Or you just open new Picture (Picture 2) field in CompanyInfo and import the logo in there.
  • Alex_ChowAlex_Chow Member Posts: 5,063
    tihomirjur wrote:
    Or you just open new Picture (Picture 2) field in CompanyInfo and import the logo in there.

    Yeah, but you need to modify a standard Navision table to do this. Nothing wrong with it, but if you can get away with not modifying, then don't.
  • JonAJonA Member Posts: 23
    I've tried to use this method to apply different bank accounts according to the country or currency to a reminder letter.

    As a complete novice I tried adding some CAL code to the report and came up with the following but I get a syntax error.

    "Issued Reminder Header - OnAfterGetRecord"

    IF "Currency Code" = '' THEN
    CompanyInfo.GET('')
    FormatAddrCodeunit.Company(CompanyAddr,CompanyInfo)
    ELSE
    IF ""Issued Reminder Header"."Country/Region Code" ='IE'THEN
    CompanyInfo.GET('IRE')
    FormatAddrCodeunit.Company(CompanyAddr,CompanyInfo)
    ELSE
    IF "Currency Code" = 'EUR' THEN
    CompanyInfo.GET('EUR')
    FormatAddrCodeunit.Company(CompanyAddr,CompanyInfo)
    ELSE END;

    Any tips gratefully received.

    Thanks
  • DenSterDenSter Member Posts: 8,304
    Some tables are supposed to have only one record, like the Company Information table. There is code in NAV all over the place that does a simple GET without a parameter, and if you enter more than one record into those tables, you might screw up the functionality without meaning to.

    For your purpose (as I've already posted in the newsgroup) I would suggest a different solution for those different bank accounts. I'm thinking about adding a bank account number to the currency table, or a table that stores bank accounts for currencies. I do not think having multiple records in the Company Information table is the right solution for you.

    Also, there are a number of issues with your syntax. I'd consider getting your NAV partner involved for some lessons in NAV development. Where I used to work we had a 1 day C/AL primer, and a 2 day reporitng class for absolute beginners.
  • JonAJonA Member Posts: 23
    Thanks DenSter

    I'm thankfully not daft enough to try this in the "Live" version and I was worried I'd have to make changes to every report which I think you've confirmed, as well as other unseen complications.

    I'm not sure if we've got the licence to add tables and it wouldn't work with just currency, it needs to choose if currency blank, standard account, if country Ireland then Irish Bank or if Currency Euro and country Not Ireland then EURO account. I'll try and add a table and see how I get on.

    I've done the report writer course but that barely touched CAL in the time we had and I'm wondering why I can't seem to find any resource to help with writing in CAL on the web, surely considering the cost of the software there should be at least a reference manual on Customer Source? I can't get another training day authorised at the moment!
    I can't get on the newsgroup either - I guess that's whay you posted here too.
  • DenSterDenSter Member Posts: 8,304
    From the Help menu, select "C/SIDE Reference Guide", in there you will find technical help. On your product disk, there is a folder called 'Doc', which contains the technical manuals. The one you're looking for is the Application Designer Guide, a file called 'w1w1adg.pdf'. Tons of information for you there :).

    What I suggested is based on having no real sense of your requirement, just a suggestion of what I'm thinking based on what you posted in here. Your actual requirement is probably much more complex, and can be solved in more than one way.

    It's not just syntax that I think you need some help with, but also some design help from an experienced consultant. Instead of trying to figure out HOW to do this, start with WHAT you need first, and discuss it with a NAV consultant. There might be a solution you haven't considered yet.
  • JonAJonA Member Posts: 23
    Thanks for that, I've found the PDF, feel stupid for not looking on the initial disk, now to 2 weeks reading!
  • DenSterDenSter Member Posts: 8,304
    Oh certainly don't feel stupid for not knowing something, that's being too hard on yourself. I didn't know about that folder until probably 2-3 years into my NAV developer career :mrgreen:
Sign In or Register to comment.