SETRANGE Issue not showing data for multiple value

mdsr
Member Posts: 163
Hi all,
i want add restriction on posting of item journal as per location for that i have done following implementation:
usersetup table:91 created field :loc. area code 200 run table adding value to this field as red|blue|green
on item jounal onaction of post addid code as:
UserSetup.RESET;
UserSetup.SETRANGE("Loc area",Rec."Location Code");
IF UserSetup.FIND('-') THEN
BEGIN
CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post",Rec);
CurrentJnlBatchName := GETRANGEMAX("Journal Batch Name");
CurrPage.UPDATE(FALSE);
END
ELSE
MESSAGE('USER NOT VALID FOR THIS LOCATION: %1',"Location Code");
now it not allowing to post user with location code as blue,and red on item journal it giviong me error message why so.
i want add restriction on posting of item journal as per location for that i have done following implementation:
usersetup table:91 created field :loc. area code 200 run table adding value to this field as red|blue|green
on item jounal onaction of post addid code as:
UserSetup.RESET;
UserSetup.SETRANGE("Loc area",Rec."Location Code");
IF UserSetup.FIND('-') THEN
BEGIN
CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post",Rec);
CurrentJnlBatchName := GETRANGEMAX("Journal Batch Name");
CurrPage.UPDATE(FALSE);
END
ELSE
MESSAGE('USER NOT VALID FOR THIS LOCATION: %1',"Location Code");
now it not allowing to post user with location code as blue,and red on item journal it giviong me error message why so.
0
Answers
-
Hi,
Because you try to find equal value RED in user setup, but you have RED|BLUE|GREEN there.
You have to use something like that:UserSetup.GET(USERID); Location.GET(Rec."Location Code"); Location.SETRECFILTER; Location.FILTERGROUP(2); Location.SETFILTER(Code, UserSetup."Loc Area"); Location.FILTERGROUP(0); IF NOT Location.FINDFIRST THEN MESSAGE('USER %1 NOT VALID FOR LOCATION %2', USERID, "Location Code");
0 -
@AlexDen thanks it working partially it allow to post user from locationRED|BlUE|GREEN but problem is it allow posting when location code is yellow which is not in user setup loc area field. why?
UserSetup.GET(USERID); Location.GET(Rec."Location Code"); Location.SETRECFILTER; Location.FILTERGROUP(2); Location.SETFILTER(Code, UserSetup."Loc area"); Location.FILTERGROUP(0); IF NOT Location.FINDFIRST THEN MESSAGE('USER %1 NOT VALID FOR LOCATION %2', USERID, "Location Code"); IF NOT Location.FINDFIRST THEN CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post",Rec); CurrentJnlBatchName := GETRANGEMAX("Journal Batch Name"); CurrPage.UPDATE(FALSE);
0 -
Try this
UserSetup.GET(USERID); Location.GET(Rec."Location Code"); Location.SETRECFILTER; Location.FILTERGROUP(2); Location.SETFILTER(Code, UserSetup."Loc area"); Location.FILTERGROUP(0); IF NOT Location.FINDFIRST THEN ERROR('USER %1 NOT VALID FOR LOCATION %2', USERID, "Location Code") ELSE BEGIN CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post",Rec); CurrentJnlBatchName := GETRANGEMAX("Journal Batch Name"); CurrPage.UPDATE(FALSE); END;
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions