SETFILTER problem, passing record to CU not working..

Hi,

on a custom form displying Prod.Order Components registered I’m trying to run CU “Production Order Status Management”.

I’m setting the focus on Prod Order record first which does not really work, so subsequently the CU starts, but it doesn’t process the desired Production Order as it has not been passed to it.

The code in OnPush is quite simple… yet i can’t figure out why the SETFILTER does not really work… tried with SETRANGE as well and passing the argument directly or through ‘%1’ does not make any difference…

ProdOrderHeader.RESET;
ProdOrderHeader.SETCURRENTKEY(“No.”);
ProdOrderHeader.SETFILTER(“No.”, ‘%1’, Rec.“Prod. Order No.”);
ProdOrderHeader.GET; // this throws error already
CODEUNIT.RUN(5407, ProdOrderHeader); // this doesnt process the record

Can you please advice where could be a problem in this??

Thanks in advance!!

Try below code please

ProdOrderHeader.RESET;

ProdOrderHeader.SETRANGE(Status,Rec.Status);

ProdOrderHeader.SETRANGE(“No.”, Rec.“Prod. Order No.”);
IF ProdOrderHeader.FINDFIRST THEN
CODEUNIT.RUN(5407, ProdOrderHeader);

Thank you very much Mohana, it has been the FINDFIRST that actually populated the record!! Works like a charm now!!!