Findset in sales order list

Hi everyone,

I’ve included a button into the sales order list, to ship all the selected ordes, and send them to a printer. The code is this one:

//1890107-01
CurrPage.SETSELECTIONFILTER(SalesOrder);
CurrPage.SETSELECTIONFILTER(lSalesOrder2);
//lSalesOrder2.COPYFILTERS(SalesOrder);
IF SalesOrder.FINDSET THEN BEGIN
  CLEAR(BillToCust);
  BillToCust.GET(SalesOrder."Bill-to Customer No.");
  CLEAR(BatchPostReport);
  BatchPostReport.SETTABLEVIEW(SalesOrder);
  BatchPostReport.InitializeRequest(TRUE,FALSE,WORKDATE,TRUE,TRUE,TRUE);
  BatchPostReport.RUNMODAL();
  CLEAR(BatchPostReport);  
  COMMIT;  
END;

//imprimir
//CurrPage.SETSELECTIONFILTER(SalesOrder);
IF lSalesOrder2.FINDSET THEN REPEAT
  //lSalesOrder2.CALCFIELDS(Shipped);
  //IF Shipped THEN
    SalesPostPrint.Print(lSalesOrder2);  
UNTIL lSalesOrder2.NEXT =0;

If I run it from the server, works correclty. But the problem comes when we run it from a client´s laptop. If we just select one order, the findset for printing works correctly. But if we select more than 1 order, the findset isn’t “finding anything”.

I’m really suspreised because the behavior is different if I run the develepment in the server or in a laptop…

Any hint? Thank you very much

Hello

This cannot happen, so your problem is not server vs. client related because the server AND the client is using the same service-tier! Having said that you need to provide more information about version of your NAV or BC365 and if you are using the WIndows-client or webclient.

Hi Palle,

Thanks for your answer. AS you said, this can¡t happen, but it is happening. I’m debugging different sessions, it’s driving me mad… We are using NAV2018, and windows client…

I would still say it is impossible because it is not the client that executes the code, it is the servicetier only and that does not matter to where the client is installed. My guess is that you are using two different users and the users are having different permissions and that is making the fuss.

Also remember that a report when it has been run the client automatically saves the filters that you have been using.

Try to go into design of your report, go to a blank line, into properties and set Save Values = FALSE and rerun the report again.

I know it’s really strange. We are using different users, but i’ve tried to run using our customer’s account, and in the server works correctly. About the reports, “BatchPostReport” report is the standard 296 record. That part of the development works correctly. The issue is with the second findset…

Now I’m using this code:

CurrPage.SETSELECTIONFILTER(lSalesOrder2);
IF lSalesOrder2.FINDSET THEN REPEAT
  lSalesOrder2.MARK(TRUE);
UNTIL lSalesOrder2.NEXT = 0;


CurrPage.SETSELECTIONFILTER(SalesOrder);
//lSalesOrder2.COPYFILTERS(SalesOrder);
IF SalesOrder.FINDSET THEN BEGIN
  CLEAR(BillToCust);
  BillToCust.GET(SalesOrder."Bill-to Customer No.");
  CLEAR(BatchPostReport);
  BatchPostReport.SETTABLEVIEW(SalesOrder);
  BatchPostReport.InitializeRequest(TRUE,FALSE,WORKDATE,TRUE,TRUE,TRUE);
  BatchPostReport.RUNMODAL();
  CLEAR(BatchPostReport);  
  COMMIT;  
END;
COMMIT;
//imprimir
//CurrPage.SETSELECTIONFILTER(SalesOrder);
lSalesOrder2.MARKEDONLY(TRUE);
IF lSalesOrder2.FINDSET THEN REPEAT
  //lSalesOrder2.CALCFIELDS(Shipped);
  //IF Shipped THEN
    SalesPostPrint.Print(lSalesOrder2);  
UNTIL lSalesOrder2.NEXT =0;
lSalesOrder2.RESET;

In the server, works perfectly as before. I’m waiting the cvustomer to cal me, and see remotely how he executes the development, may ve he’s doing something different… It’s driving me mad all this…

Thanks for your answers

Update:

I’ve executed remotely with the customer the process. He selected 2 orders. In the repeat where i mark to TRUE the roders, we see 2 loops, so it’s marking correctly both orders.

The orders are also been correclty registered.

But in the last findset, where I search for marked orders, isn’t fitting the FINDSET condition, so it isn’t doing the print function…

what is salespostprint?

it is the 82 codeunit.

NEW UPDATE:

I’ve seen how does our customer make the execution. He doesn’t register orders direclty from the sales order list. He has made a view, with different filters, and he’s executing from there, so probably, does filters are messing all the development…

I knew that it was impossible the development work different way, It needed to be something like that…

knew it it was CU 82 just wanted confimration.

use printrecords function in the sales invoice header table. I believe you are trying to print invoices?

I’m printing shipments

you could use same function in the sales shipment header

/CurrPage.SETSELECTIONFILTER(SalesOrder);
IF lSalesOrder2.FINDSET THEN REPEAT
//lSalesOrder2.CALCFIELDS(Shipped);

Why FINDSET with lSalesOrder2??

Well there is so much wrong with that code, that you should not worry about it :slight_smile:

Well, All the variables and lSalesOrder2 where created after hours of trying to work the development, there are really no needed. They were used for different tests, thinking about that maybe the filters where cleared in process or something… Because I was getting mad, and at the end was that the customer was using a view with filters instead of the page itself…

Of course, the code is more simple than this, it’s very different