The Record variable must belong to 37 and not to 0.

Big_DBig_D Member Posts: 207
edited 2014-10-23 in NAV Three Tier
Hi mibuso.com world :D

Here's a strange one alright in the following std code in cu80...

IF "Document Type" IN ["Document Type"::"Return Order","Document Type"::"Credit Memo"] THEN
CheckApplFromItemEntry := Quantity > 0
ELSE
CheckApplFromItemEntry := Quantity < 0;

I received the above error on CheckApplFromItemEntry but this is a Boolean field and not anything to do with the Sales Line Table!

The client just graduated from 2009 R2 Build 32775 to 33154.

I fixed it by introducing a new Boolean field and using that instead but just wondering if any of you guys out there have a reply to why this happened in the first place!

With thanks
Big D signing off!

Comments

  • SogSog Member Posts: 1,023
    CheckapplFromItemEntry is a local var, not a field.
    Second, even though the debugger stopped on that statement, doesn't mean that it actually stopped on that statement. (Thanks to the debugger).
    It could have stopped on the statement just above. And then you have the "document type" which is part of record 37.
    I see 2 options for this, either the "with salesline do" a whole lot sooner in the code, might be closed too soon, or
    the salesline has been cleared due to some reason, and an unitialised rec is of table 0.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • ChinmoyChinmoy Member Posts: 359
    Hi,

    To reproduce your error message I just changed the data type of the variable to Record and specified the tableno as 37. Tried to compile it and got the same message - "The Record variable must belong to 37 and not to 0."

    Deleted the variable and re-created it and the cu80 got compiled again. I guess something very odd must have happened, and the compiler was somehow convinced that the variable is the Sales Line table.

    I could not find any other explanation to this... :(

    Chn
  • Big_DBig_D Member Posts: 207
    Hi Chinmoy and Sog

    Thanks for your replies :D! Yes you have found a way to duplicate it - think I'll create a case to send to Microsoft - will let you know if I get a viable reason!

    With thanks
    Big D signing off!
  • ChinmoyChinmoy Member Posts: 359
    You are welcome! :)
  • Big_DBig_D Member Posts: 207
    Hi Chinmoy

    Had a reply from MS and this was their reply...

    when changing to Record 37, the issue is because you're assigning a boolean to a record. Same issue can be reproduced by adding two new records variable (e.g. rec27 with subtype 27 and rec18, subtype 18) and:
    rec27 := rec18; will give "The Record variable must belong to 27 and not to 18"
    rec27 := FALSE; will give "The Record variable must belong to 27 and not to 0"

    They were correct - change the SalesLine variable to point at the customer table (you'll have to comment out the code to see the error) - compile and yes as they said! So behind the scenes or something has an establish link to its original value - strange!

    Any way they recommend upgrading to 33346!

    Big thanks for your help
    Big D signing off!
  • ChinmoyChinmoy Member Posts: 359
    Thanks for the info Ben!
  • colingbradleycolingbradley Member Posts: 162
    NAV2009R2 Build 32012

    I had a similar problem in a report, I changed the DataItem Name from the default name to a variable, <Revenue Type> to RevenueTypeDataItem.

    Thanks to this forum, my sanity was saved!
    There is no real indication of why I got the message but it seems that the compiler got confused.

    It might explain why you may see a DataItem Name as a variable in some standard reports.
    Experience is what you get when you hoped to get money
Sign In or Register to comment.