Options

No data in record to work with in the page

HenrikDKHenrikDK Member Posts: 14
edited 2011-05-06 in NAV Three Tier
Hey,

I have placed some code on the OnInsertRecord trigger on a page. This code checks if the date is already in the table and if it is, the current record is updated with the quantity of the new record and the new record is not inserted. The problem is that I can not see the record data from the Web Service. In the example below, the date variable is empty eventhough it is passed through to the insert trigger on the tabel with a real date. Is it not possible to work with the record data on the page? And if not, do you have an idea where I can place the code instead to prevent the new record from being created.
lTabel.SETRANGE(lDate.Date,rec.Date);
IF lTabel.FINDFIRST THEN BEGIN
  lTabel.Quantity += rec.Quantity;
  lTabel.MODIFY(TRUE);
  EXIT(FALSE);
END ELSE
  EXIT(TRUE);

I hope it make sence and that someone can help.

/Henrik

Comments

  • Options
    SogSog Member Posts: 1,023
    AFAIK I can't answer your first question.
    The if it is not possible clause I can answer:
    In the case of a custom table:
    You could make the date (or date + item no. although that's just guessing) your primary key.
    Then there is no way that the record could be inserted.
    Or you could place the code in your oninsert trigger of the table.
    Or something else.
    But I'm thinking that it might be a flawed solution altogether.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • Options
    ufukufuk Member Posts: 514
    Why don't you write your code on .Net? Something like:
       TempPage_Binding tempSrv = new TempPage_Binding();
       NAVConn.PrepTempBinding(ref tempSrv);
       TempPage tempPage = new TempPage();
                
       List<TempPage_Filter> filterArray = new List<TempPage_Filter>();
       TempPage_Filter dateFilter = new TempPage_Filter();
    
       dateFilter.Field = TempPage_Fields.Posting_Date;
       dateFilter.Criteria = varDateFilter.ToString();
       filterArray.Add(dateFilter);
       
       TempPage[] TempPage = tempSrv.ReadMultiple(filterArray.ToArray(), null, 0);
       if (TempPage.Length > 0)
       {
                    TempPage[1].Quantity += varQty;
                    tempSrv.Update(ref tempPage);
        }
        else
        {
                    tempPage = new TempPage();
                    tempPage.Entry_No = pEntryNo;
                    TempPage[1].QuantitySpecified = true;
                    tempPage.Quantity = varQty;
                    tempSrv.Create(ref tempPage);
         }
    
    Ufuk Asci
    Pargesoft
Sign In or Register to comment.