Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Timesheet creation by code

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

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee 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

  • DONA Profile Picture
    DONA 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

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,113 Super User 2024 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?

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans