How does GET work here?

Hi, I am a beginner in Navision and learning the Development. I hope many seniors and experienced people are here to guide freshers like me. From C/Side reference manual I learnt… [Here is copied direclty from C/Side help] GET: Use these functions to find a record based on values stored in primary key fields. [Ok :=] Record.GET([Value] ,…) but in Code unit 408, (dimensionmanagement) in GLSETUP() function it says IF NOT HasGotGLSetup THEN BEGIN GLSetup.GET; -----> what does this get function get?(with out a value being passed) and also “hasgotglsetup” is a variable of boolean type so it is intially 0(no) always. So every time it obviously goes to GLSetup.GET; So why are we using this “IF NOT HasGotGLSetup”. I have seen this type of approach in a lot of places. Does this signifies any specific function. Or my understanding is wrong somewhere? Please clarify my doubt. Thanks in advance to all who read this. wiating for a reply. Best Regards, Alex.

Hi Alex, If you don’t specify a value, the system will just retrieve the first record. Since GET doesn’t use filtering, you wouldn’t normally use it without a value. However, in this case the system is lookup for a setup record - since you only have one setup record in the table, there is no need to tell the system which record you want to get. I didn’t look too closely at the condition, but you will notice that the boolean is set to TRUE if the condition is met, meaning it will fail to meet the condition a second time. This function is called multiple times throughout the codeunit, so I presume it is to stop the system from assiging the values to the dimensions more than once. Hope that’s of some help.

Hi Kristian Bara, Thanks for clarifying.I got it. & now my question looks foolish to me…! Best Regards, Alex

quote:


Originally posted by Kbara
…, the system will just retrieve the first record. …


Actually that’s wrong. If you do not provide a paramater, then the system assumes the “Init” value for that field type. In this case (Code) the value is blank, so the following are identical GLSetup.GET; and GLSetup.GET(''); A more complex example would be for a sales line, in which case SalesLine.GET; and SalesLine.GET(SalesLine."Document Type"::Quote,'',0); would be the same

Right you are, but my answer was the best help he was going to get on Easter Sunday [;)]

So true… but we need to make sure that when people ask for help, that they get it right [;)]

Just to add one more bit of info for Alex: GET works on the Primary Key and goes back to the database table - it ignores the recordset and thus ignores any filters. Also the HasGotGLSetup boolean will usually be set to True right after calling GLSetup.GET; It’s an efficiency thing - you’ll likely need to access the GLSetup several times in a particular transaction. Django

Hi, Thanks for your replies.This forum has been very helpful in Learning Navision. Best Regards, Alex