Options

GET multiple records from subpage

pruebasExpruebasEx Member Posts: 51
edited 2017-10-18 in NAV Three Tier
I'm trying to replace an GETRECORD function wicht only returns one record (one you were select before this function is called) with another to MARK all the lines from a subpage from a page.

I have a page where you can create a header and the lines(in a subpage). The problem it's when I try to call a function wicht creates a copy of this (header and lines) we have had create right now.

I use this code to get the lines that are at the lines subpage.


IF CONFIRM('¿Create a new petition?') THEN
  BEGIN
    TempCabPeticion.RESET;
    TempCabPeticion.INIT;
    IF TempCabPeticion.FIND('-') THEN
      TempCabPeticion.DELETEALL;
    TempCabPeticion."Cód. petición" := '';
    TempCabPeticion.INSERT(TRUE);
    CabPeticion.RESET;
    CabPeticion.TRANSFERFIELDS(Rec);
    CabPeticion."Cód. petición" := TempCabPeticion."Cód. petición";
    CabPeticion."Estado petición" := CabPeticion."Estado petición"::Nueva;
    CabPeticion.INSERT;
    //LinPeticion.RESET;
    //CurrPage.LineasPeticion.PAGE.GETRECORD(LinPeticion);THIS is the old line, only returns one Line

CurrPage.LineasPeticion.PAGE.SETTABLEVIEW(LinPeticion);
CurrPage.LineasPeticion.PAGE.LOOKUPMODE(TRUE);
IF CurrPage.LineasPeticion.PAGE.RUNMODAL = ACTION::LookupOK THEN BEGIN
   SelectedRecord := LinPeticion;
   CurrPage.LineasPeticion.PAGE.SETSELECTIONFILTER(SelectedRecord);
   SelectedRecord.MARKEDONLY(TRUE);
   IF NOT SelectedRecord.FINDFIRST THEN BEGIN
          CurrPage.LineasPeticion.PAGE.GETRECORD(ActiveRecord);
      END ELSE BEGIN
      REPEAT
         MESSAGE('Some items were selected');
      UNTIL SelectedRecord.NEXT = 0;
   END;
END;   



ERROR

The following C/AL functions can be used only to a limited degree during write transactions (because one or more tables will be locked).

Form.RunModal() is not allowed in write transactions.

CodeUnit.Run() is allowed in write transactions only if the return value is not used. For example, 'OK := CodeUnit.Run()' is not allowed.

Report.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'Report.RunModal(...,FALSE)' is allowed.

DataPort.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'DataPort.RunModal(...,FALSE)' is allowed.

Use the COMMIT function to save the changes before this call, or structure the code differently.
ERROR

Answers

  • Options
    YuryYury Member Posts: 59
    Hi, pruebasEx
    If you want to create copy of document, why you don't use a function from the header of existed document? I have such function for copy of Purchase Blanket Order to another. User opens order to be copied, chooses lines with selection and clicks "create new" function. After that I open new document by simple RUN. What for are you using RUNMODAL?

    Un saludos
    Regards,
    Yury
  • Options
    TModestTModest Member Posts: 6
    Hello,
    Normaly i use settableview to show me a page where the filters of the record that i want are done before i use it. I know for a fact that you want to push ok to show the page after some code. What i can't understand is why using "LinPeticion.RESET;" before the tableview. I suggest that you comment this piece of code and make sure the record is filtered as you want it to be.
    One more thing, the begining of the code it isn't 100 % fluid, you are using 3 steps to insert some variable but in fact you can do it with 2 steps. There is no need to insert in the temporary table.
  • Options
    pruebasExpruebasEx Member Posts: 51
    TModest wrote: »
    Hello,
    Normaly i use settableview to show me a page where the filters of the record that i want are done before i use it. I know for a fact that you want to push ok to show the page after some code. What i can't understand is why using "LinPeticion.RESET;" before the tableview. I suggest that you comment this piece of code and make sure the record is filtered as you want it to be.
    One more thing, the begining of the code it isn't 100 % fluid, you are using 3 steps to insert some variable but in fact you can do it with 2 steps. There is no need to insert in the temporary table.
    Yes I know, but this client dont want to change anything if it's not any error. :neutral:

    I made a lot of changes in the original, the line of RESET was commented. I'll fix it.


    Thanks.

  • Options
    kvbkvb Member Posts: 107
    edited 2017-10-24
    pruebasEx wrote: »
    The problem it's when I try to call a function wicht creates a copy of this (header and lines) we have had create right now.

    Hi pruebasEx, you have a lot steps ahead, but welcome)

    I would suggest you first take all the inputs from the user and only then do the INSERT transaction itself.
    Then you will not have that error about 'Use COMMIT...' bla-bla-bla.

    So first any PAGE.RUNMODAL`s and only after it INSERT`s, MODIFY`s and whatever you wanna do with data.
Sign In or Register to comment.