web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Timesheet creation by code

(0) ShareShare
ReportReport
Posted on by 642

Hi,

Someone has already created timesheet line by code. The record is created but I don't see the result in my form. Maybe I forgot something in my code :

TSTimesheetTable        tsTimesheetTable = TSTimesheetTable::find("XXXXXXXXX");    

TSTimesheetLine         tTimesheetLine;

 tTimesheetLine.ProjId      = "YYYYYYYYY";  

tTimesheetLine.TimesheetNbr    = tsTimesheetTable.TimesheetNbr;

 tTimesheetLine.ProjPeriodTimesheetWeek  = tsTimesheetTable.RecId;

 tTimesheetLine.ProjectDataAreaId   = curext();  

tTimesheetLine.initValue();

 if (tTimesheetLine.validateWrite())

 {   

tTimesheetLine.insert();

TSTimesheetLineWeek::loadFromLine(tTimesheetLine, NoYes::No);

 }

Thanks in advance

 

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    300,721 Super User 2025 Season 2 on at
    RE: Timesheet creation by code

    Hi,

    Check the form datasources used. There are usually also records created in the table TsTimesheetTrans. Is there one or more corresponding records in this table created with above code?

  • DONA Profile Picture
    642 on at
    RE: Timesheet creation by code

    Hi,

    I had checked the form datasources. The TsTimesheetTrans is filled when you encoded hours... I have tried many. The data genered by code seems the same (in tables line and lineweek) but I spend side of something.

    Have you already created lines for thimesheet by code?

    Best regards

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Timesheet creation by code

    Dona83,

    I just dealt with the same problem, and as our company has been creating a time tracking app for AX in C# and using AIF Services.    A few things that helped us track down how to implement were:

    1) Compare data in these tables between what the AX client generates and what you are doing:  

    select * from TSTIMESHEETTABLE
    select * from TSTIMESHEETLINE
    select * from TSTIMESHEETLINEWEEK
    select * from TSTIMESHEETTRANS

    2) Review the code under \Classes\TSTimesheetService  in AOT.   I wound up rewriting some of the code in there but it's a great place to see what's going on under the hood.   Check out these methods:   createNewTimesheet, createOrUpdateTimeEntry, createOrUpdateTimesheetLines

    3) It could be something we misconfigured, but if you require start-stop times, you might find the transactions are not getting created by the methods in (2), so you might need to roll your own method for that.  

    Reply if you want to look at some code.  :-)
    -Brian

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 AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans