Dynamics NAV 2013 R2 OData

hubix2000hubix2000 Member Posts: 3
edited 2013-11-14 in NAV Three Tier
Hi,

I'm trying to call the page 5404 ("Item Units of Measure") through a web service. Whenever I'll open it I'll get this error "The Item does not exist. Identification fields and values: No.=''". Same error occours when I run this page from within C/Side.

The reason for this is this line:
  OnOpenPage()
  Item.GET("Item No.");When I call this page through the OData service Rec.Fields."Item No." is unset.

Question now is: How to set it from an OData call?

Thanks for your help,

Jörg

Comments

  • kinekine Member Posts: 12,562
    Are you filtering on specific Item when calling the OData?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • hubix2000hubix2000 Member Posts: 3
    Hi,

    I'm trying to query the data like this;
    var iUsoM = from iUoM in this.Nav.ItemUnitsOfMeasure
                       select iUoM;
    

    Another try Fails as well:
    var iUsoM = from iUoM in this.Nav.ItemUnitsOfMeasure
                       where iUoM.Item_No = "1001"
                       select iUoM;
    

    Both results are the same.
    The Problem is that Rec.Fields."Item No." is not set and this is used in OnOpenPage().
    First line does Item.GET("Item No.");. This Fails.

    So, how to set Rec.Fields."Item No." from an OData request?

    Kind Regards
    Jörg
  • thegunzothegunzo Member Posts: 274
    Hi

    If the page is note being called by a valid "Item Unit of Measure" record then the "Item No." will be blank in OnOpenPage trigger.
    Try to move your Item.GET code to OnAfterGetRecord trigger and change if to

    IF NOT Item.GET(...) THEN
    Item.INIT;
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • Jens_M-PJens_M-P Member, Microsoft Employee Posts: 39
    It is correct that not all pages can be exposed succesfully as an OData feed. This is especially true if the page requires a certain context to run.
    In those cases you will have to either refactor the page or create a dedicated codeunit/page/xmlport or Query that you can expose.
    Best regards,
    Jens Møller-Pedersen [MSFT]

    This posting is provided 'AS IS' with no warranties, and confers no rights.
Sign In or Register to comment.