Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

We can use FieldRef and Function to reduce codes in Easy Security and use Group filter to reduce setup

Posted on by 554


'UF_MORESPO':
EXIT(GetUserFilter(ESUserFilter.FIELDNO(ESUserFilter."Production Resp. Ctr. Filter")));

'UF_MODFLOC':
EXIT(GetUserFilterDefault(ESUserFilter.FIELDNO(ESUserFilter."Default Prod. Location")));

ELSE
ESDynamicFilter.ShowCalculationError;
END;
END;

PROCEDURE InsertFilters@1240520002(CalculationCodeunitID@1240520003 : Integer);
VAR
ESDynamicFilter@1240520002 : Record 14123818;
ESUserFilter@1000000000 : Record 14123819;
BEGIN
// Add Code to insert new Dynamic Filters
// ESDynamicFilter.InsertDynamicFilter('MYTIME',CalculationCodeunitID,'Current Time');

ESDynamicFilter.InsertDynamicFilter(
'UF_MORESPO',CalculationCodeunitID,ESUserFilter.FIELDCAPTION("Production Resp. Ctr. Filter"));
//#003 >>
ESDynamicFilter.InsertDynamicFilter(
'UF_MODFLOC',CalculationCodeunitID,ESUserFilter.FIELDCAPTION("Default Prod. Location"));

END;

PROCEDURE GetGroupFilter@1000000000(P_FieldNo@1000000001 : Integer) : Code[80];
VAR
GroupUserSetup@1000000003 : Record 14123817;
ESUserGroupFilter@1000000002 : Record 14123819;
L_RecordRef@1000000000 : RecordRef;
L_FieldRef@1000000004 : FieldRef;
L_Filter@1000000005 : Text[150];
BEGIN
L_Filter := '''''';

GroupUserSetup.RESET;
GroupUserSetup.SETRANGE(GroupUserSetup."Member User ID",USERID);
IF GroupUserSetup.FINDFIRST THEN BEGIN
IF ESUserGroupFilter.GetUser(GroupUserSetup."Group User ID") THEN BEGIN
L_RecordRef.GETTABLE(ESUserGroupFilter);
L_FieldRef := L_RecordRef.FIELD(P_FieldNo);
L_Filter := L_FieldRef.VALUE;
IF L_Filter <> '' THEN
EXIT(L_Filter)
ELSE
EXIT(''''''); 

END ELSE
EXIT(''''''); 

END ELSE
EXIT(''''''); 
END;

PROCEDURE GetUserFilter@1000000002(P_FieldNo@1000000001 : Integer) : Code[80];
VAR
GroupUserSetup@1000000003 : Record 14123817;
ESUserFilter@1000000002 : Record 14123819;
L_RecordRef@1000000000 : RecordRef;
L_FieldRef@1000000004 : FieldRef;
L_Filter@1000000005 : Text[150];
BEGIN
IF ESUserFilter.GetUser(USERID) THEN BEGIN
L_RecordRef.GETTABLE(ESUserFilter);
L_FieldRef := L_RecordRef.FIELD(P_FieldNo);
L_Filter := '';
L_Filter := L_FieldRef.VALUE;
IF L_Filter <> '' THEN
EXIT(L_Filter)
ELSE
EXIT(''''''); 

END ELSE BEGIN
EXIT(GetGroupFilter(P_FieldNo));
END;
END;

PROCEDURE GetGroupUserFilterDefault@1000000003(P_FieldNo@1000000001 : Integer) : Code[80];
VAR
GroupUserSetup@1000000003 : Record 14123817;
ESUserGroupFilter@1000000002 : Record 14123819;
L_RecordRef@1000000000 : RecordRef;
L_FieldRef@1000000004 : FieldRef;
L_Filter@1000000005 : Text[150];
BEGIN
//Default
L_Filter := '';

GroupUserSetup.RESET;
GroupUserSetup.SETRANGE(GroupUserSetup."Member User ID",USERID);
IF GroupUserSetup.FINDFIRST THEN BEGIN
IF ESUserGroupFilter.GetUser(GroupUserSetup."Group User ID") THEN BEGIN
L_RecordRef.GETTABLE(ESUserGroupFilter);
L_FieldRef := L_RecordRef.FIELD(P_FieldNo);
L_Filter := L_FieldRef.VALUE;
IF L_Filter <> '' THEN
EXIT(L_Filter)
ELSE
EXIT(''); 

END ELSE
EXIT(''); 

END ELSE
EXIT(''); 
END;

PROCEDURE GetUserFilterDefault@1000000001(P_FieldNo@1000000001 : Integer) : Code[80];
VAR
GroupUserSetup@1000000003 : Record 14123817;
ESUserFilter@1000000002 : Record 14123819;
L_RecordRef@1000000000 : RecordRef;
L_FieldRef@1000000004 : FieldRef;
L_Filter@1000000005 : Text[150];
BEGIN
IF ESUserFilter.GetUser(USERID) THEN BEGIN
L_RecordRef.GETTABLE(ESUserFilter);
L_FieldRef := L_RecordRef.FIELD(P_FieldNo);
L_Filter := '';
L_Filter := L_FieldRef.VALUE;
IF L_Filter <> '' THEN
EXIT(L_Filter)
ELSE
EXIT(''); 

END ELSE BEGIN
EXIT(GetGroupUserFilterDefault(P_FieldNo));//Default
END;
END;

*This post is locked for comments

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans