Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Return a filtered value of USERID() in CalcFormula.

(0) ShareShare
ReportReport
Posted on by 358
I am creating a RoleCenter that will pull the total attendance of currently logged in user.
There is a table, let us call it MyTable that has records with the following columns.
Employee Code, Absent (this is a checkbox).
The Cue Table I have created for the RoleCentre I am creating, I created a field "Total Attendance" and want to write the following formula on its CalcFormula.
Filter through MyTable records with Employee Code that you find from USERID() then filter records with Absent unchecked.
This is how my CalcFormula looks as of now and I don't know how to properly user USERID() to get the Employee Code and then pass this value in the CalcFormula.
table 50043 "Cue Attendance"
{
    DataClassification = CustomerContent;
    fields
    {
        field(1; "Primary Key"; Integer)
        {
            DataClassification = CustomerContent;
        }
        field(2;"Total Attendance"; Integer)
        {
           FieldClass = FlowField;
           CalcFormula = count("MyTable" where("Employee Code" = filter(USERID)));
        }
    }
    keys
    {
        key(PK; "Primary Key")
        {
            Clustered = true;
        }
    }

*This post is locked for comments

  • ChazKimRP Profile Picture
    ChazKimRP 380 on at
    RE: Return a filtered value of USERID() in CalcFormula.

    When I was creating cues to look at the current logged in user,  I did the following:

    Table:

           field(2;UserIDFilter; Code[20])

           {

               FieldClass = FlowFilter;

           }

    Cue Page:

       trigger OnOpenPage();

       var

       begin

                   Reset;

           If not get then begin

               INIT;

               INSERT;

           end;

           SetRange(UserIDFilter, UserId);

    Try this out. This way the code is farther away from the table field.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 44,656 on at
    RE: Return a filtered value of USERID() in CalcFormula.

    You cannot use USERID in the calcformulae. Create a flowfilter called User ID Filter in the table and use that in the Calcforumulae, then on the OpenPage of the Rolecenter add the filter SetRange("User ID Filter",UserID)

    Check the Finance Cue table for Example and Account Activities Role Center Page 9037

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,436 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans