web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Suggested answer
    Suresh Kulla Profile Picture
    50,245 Super User 2025 Season 2 on at

    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

  • ChazKimRP Profile Picture
    380 on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans