AIF - Custom Inbound Service - TSTimesheetTable (AX 2012R2) - Problem populating attribute which is based on child entity

Hi there,

I created a custom inbound service to create timesheets. Everything works fine besides one attribute I have to populate. This is my query:

TSTimesheetTable → TSTimesheetLine → TSTimesheetLineWeek

My problem is that I have to populate attribute/field [ProjPeriodTimesheetWeek]. In order to do that I need a PeriodId (got it) and the DayFrom (have this in the line week). My problem is that I don’t know how to populate this value since I can’t access the child entity (TSTimesheetLineWeek) when populating the TSTimesheetLine entity. The code below shows the way I would like to populate the ProjPeriodTimesheetWeek:

AxTSTimesheetLine.parmProjPeriodTimesheetWeek(ProjPeriodTimesheetWeek::find(AxTSTimesheetTable.parmProjPeriodId(), AxTSTimesheetLineWeek.parmDayFrom()).RecId);

Is there any way to insert the parent entity (TSTimesheetLine) without the ProjPeriodTimesheetWeek and

  1. update the parent entity when processing the child entity?

  2. update the entity after processing all child entities?

  3. Is there a better way?

I hope this makes sense. Thanks for the help!!!