Change Posting Date

Hi Everybody,

I write code change posting date but it’s not work. After code work I will run job Queue auto. I use 2 table

UserType Record User
UserRec Record User Setup

UserRec.RESET;
//UserType.RESET;
UserType.SETRANGE("User Name",UserRec."User ID");
IF UserRec.GET(UserType."User Name") THEN BEGIN
  IF UserRec.FINDSET THEN REPEAT
    UserType.SETFILTER("User Posting Type",'%1',UserType."User Posting Type"::Warehouse);
    UserRec."Allow Posting From":=TODAY;
    UserRec."Allow Posting To" := TODAY;
    UserRec.MODIFY;
  UNTIL UserRec.NEXT=0;
END;

Please help me fix code.

Thanks so much

Hi
Use ‘if usertype.findfirst then’ after setrange.
Neil

Hi Neil Fraser,

After I edit code it’s work. But it’s can’t filter by UserType.“User Posting Type”::Warehouse.

It’s will modify all record.

//UserType.RESET;
UserRec.RESET;
UserType.SETFILTER(UserType."User Posting Type",'%1',UserType."User Posting Type"::Warehouse);
  IF UserRec.FINDFIRST THEN REPEAT
    UserType.SETRANGE(UserType."User Name",UserRec."User ID");
    UserType.SETFILTER(UserType."User Posting Type",'%1',UserType."User Posting Type"::Warehouse);
    UserRec."Allow Posting From":=TODAY;
    UserRec."Allow Posting To" := TODAY;
    UserRec.MODIFY;
  UNTIL UserRec.NEXT=0;

Please help me. Thanks so much.

Hi.
Which tables are userrec and usertype
Neil

Hi Neil,

UserType Record User
UserRec Record User Setup

Thanks

Hi
Doing this off my iPad which is not easy. Could you email your code as text file to neil@fpconsult.co.uk and I will look at tomorrow when I am back at work?

Neil