Is RecRef.SETPOSITION broken in 2013r2?

DanKDanK Member Posts: 34
edited 2013-10-08 in NAV Three Tier
I'm getting an error in 2013R2; "The server "DynamicsNAV71" was unable to process the request. The application will close."

It's being caused by code which is working fine in NAV2013, for example:
aRecordVar.FINDFIRST;
recref.open(DATABASE::TableName);
recref.SETPOSITION(aRecordVar.GETPOSITION);
recref.FINDFIRST;

Anyone else getting the same issue?

Event log:
Type: System.ArgumentException
Message: An item with the same key has already been added.
StackTrace:
     at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
     at Microsoft.Dynamics.Nav.Runtime.NCLMetaTable.<TryGetFieldByCaption>b__e(Int32 lcid)
     at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
     at Microsoft.Dynamics.Nav.Runtime.NCLMetaTable.TryGetFieldByCaption(String name, NCLMetaField& result)
     at Microsoft.Dynamics.Nav.Runtime.NCLMetaTable.FindFieldMatch(String fieldIdentifier, Boolean prefixFallback)
     at Microsoft.Dynamics.Nav.Runtime.TableFilterResolver.AddFilter(String fieldName, NCLMetaFilterType filterType, String expressionString)
     at Microsoft.Dynamics.Nav.Runtime.TableViewParser.ProcessWhere(String input, Match match, TableFilterResolver resolver)
     at Microsoft.Dynamics.Nav.Runtime.RecordImplementation.SetPosition(String position)
     at Microsoft.Dynamics.Nav.Runtime.NavRecord.ALSetPosition(String position)
     at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit61800.OnRun_Scope.OnRun()
     at Filter.InvokeWithFilter(NavMethodScope )
     at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit61800.OnRun(INavRecordHandle εrec)
     at Microsoft.Dynamics.Nav.Runtime.NavCodeunit.DoRun(DataError errorLevel, NavRecord record)
     at Microsoft.Dynamics.Nav.Runtime.NavCodeunit.InvokeRun(Int32 objectId, Object[] args)
     at Microsoft.Dynamics.Nav.Service.NSCodeUnit.RunCodeunit(CodeUnitResponse codeUnit)
     at Microsoft.Dynamics.Nav.Service.NSCodeUnit.Invoke()
     at SyncInvokeInvokeApplicationMethod(Object , Object[] , Object[] )
     at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
     at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.ErrorMappingCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
Source: mscorlib
HResult: -2147024809

Answers

  • amazanamazan Member Posts: 17
    Hi Dank,

    I've tested your code with GLSetup and works fine with Codeunits in NAV 2013 R2 W1.
    OBJECT Codeunit 80000 Test Mibuso
    {
      OBJECT-PROPERTIES
      {
        Date=08/10/13;
        Time=15:40:03;
        Modified=Yes;
        Version List=amazan;
      }
      PROPERTIES
      {
        OnRun=BEGIN
                GLSetup.FINDFIRST;
                recref.OPEN(DATABASE::"General Ledger Setup");
                recref.SETPOSITION(GLSetup.GETPOSITION);
                recref.FINDFIRST;
                MESSAGE ('finished');
              END;
    
      }
      CODE
      {
        VAR
          recref@1000 : RecordRef;
          GLSetup@1001 : Record 98;
    
        BEGIN
        END.
      }
    }
    

    Greetings
  • DanKDanK Member Posts: 34
    Hi Amazan,

    Thanks for testing it out.

    This error seems to be happening with some but not all tables, still trying to find some commonality between them.

    Dan.
  • matteo_montanarimatteo_montanari Member Posts: 189
    DanK wrote:
    Hi Amazan,

    Thanks for testing it out.

    This error seems to be happening with some but not all tables, still trying to find some commonality between them.

    Dan.

    Hi

    I tested a NAV2013r2 Italian database and this works fine:
    Window.OPEN('#1#############################');
    
    Object.SETRANGE(Object.Type, Object.Type::TableData);
    Object.SETFILTER(ID, '..49999|99000000..');
    IF Object.FINDSET THEN
      REPEAT
        TextLine := '';
        Window.UPDATE(1, Object.Name);
        RecRef.OPEN(Object.ID, FALSE, Object."Company Name");
        IF RecRef.FINDFIRST THEN
          TextLine := RecRef.GETPOSITION;
        RecRef.CLOSE;
    
        IF TextLine <> '' THEN BEGIN
          RecRef2.OPEN(Object.ID, FALSE, Object."Company Name");
          RecRef2.SETPOSITION(TextLine);
          RecRef2.CLOSE;
        END;
    
      UNTIL Object.NEXT = 0;
    Window.CLOSE;
    

    Matteo
    Reno Sistemi Navision Developer
  • matteo_montanarimatteo_montanari Member Posts: 189
    edited 2013-10-08
    DanK wrote:
    Hi Amazan,

    Thanks for testing it out.

    This error seems to be happening with some but not all tables, still trying to find some commonality between them.

    Dan.

    Hi

    I tested a NAV2013r2 Italian database and this works fine:
    Window.OPEN('#1#############################');
    
    Object.SETRANGE(Object.Type, Object.Type::TableData);
    Object.SETFILTER(ID, '..49999|99000000..');
    IF Object.FINDSET THEN
      REPEAT
        TextLine := '';
        Window.UPDATE(1, Object.Name);
        RecRef.OPEN(Object.ID, FALSE, Object."Company Name");
        IF RecRef.FINDFIRST THEN
          TextLine := RecRef.GETPOSITION;
        RecRef.CLOSE;
    
        IF TextLine <> '' THEN BEGIN
          RecRef2.OPEN(Object.ID, FALSE, Object."Company Name");
          RecRef2.SETPOSITION(TextLine);
          RecRef2.CLOSE;
        END;
    
      UNTIL Object.NEXT = 0;
    Window.CLOSE;
    

    Matteo


    mmm One question...

    Try "GETPOSITION(FALSE);" instead of "GETPOSITION;"

    I think you have a custom table with 2 field with different names but same caption.

    can it be?

    Matteo
    Reno Sistemi Navision Developer
  • matteo_montanarimatteo_montanari Member Posts: 189
    wow nice :

    I created a new custom table with 2 fields with different names but same italian caption (no ENU caption).

    If i set my language to Italian:
    GETPOSITION(TRUE) RTC client will crash.
    GETPOSITION(FALSE) works.

    If i set English it works both true or false parameter.

    very nice!

    Matteo
    Reno Sistemi Navision Developer
  • DanKDanK Member Posts: 34
    wow nice :

    I created a new custom table with 2 fields with different names but same italian caption (no ENU caption).

    If i set my language to Italian:
    GETPOSITION(TRUE) RTC client will crash.
    GETPOSITION(FALSE) works.

    If i set English it works both true or false parameter.

    very nice!

    Matteo

    You cracked it! Nice one Matteo!

    GETPOSITION(FALSE) sorted the issue =D>
Sign In or Register to comment.