If(
IsBlank(ddlResource.Selected),
Notify("Select a Resource.", NotificationType.Error),
IsBlank(dpDate.SelectedDate),
Notify("Select a Date.", NotificationType.Error),
varTypeBC = "Project" && (IsBlank(jobNo.Selected) || IsBlank(jobTaskNo.Selected)),
Notify("Select a Project and a Job Task.", NotificationType.Error),
varTypeBC = "Absence" && IsBlank(cmbAbsence.Selected),
Notify("Select a Cause of Absence.", NotificationType.Error),
!IsNumeric(txtQuantity.Text) || Value(txtQuantity.Text) <= 0,
Notify("Enter a positive number of hours.", NotificationType.Error)
);
Set(
varWeekStart,
DateAdd(dpDate.SelectedDate, 1 - Weekday(dpDate.SelectedDate, StartOfWeek.Monday), TimeUnit.Days)
);
Set(
varHeader,
LookUp(
'timesheetheaderpowerapps (clobotics/finance/v1.0)',
'Starting Date' = varWeekStart &&
'Resource No.' = ddlResource.Selected.'No.'
)
);
If(IsBlank(varHeader),
Notify("Timesheet Header not found! Cannot create line.", NotificationType.Error)
);
Set(
varAccountingPeriod,
LookUp(
SortByColumns(
Filter(
'abiAccountingPeriods (abakion/bi/v2.0)',
'Starting Date' <= dpDate.SelectedDate && Closed = false
),
"startingDate",
SortOrder.Descending
),
true
)
);
If(IsBlank(varAccountingPeriod),
Notify("No open accounting period found for the selected date.", NotificationType.Error)
);
Set(
varPeriodStart,
DateAdd(
Date(1970,1,1),
Value(varAccountingPeriod.'Starting Date') / 1000,
TimeUnit.Seconds
)
);
Set(
varLine,
Patch(
varHeader,
Defaults('timesheetlinepowerapps (clobotics/finance/v1.0)'),
{
'Project No.': jobNo.Selected.'No.',
'Project Task No.': jobTaskNo.Selected.'Project Task No.',
'Work Type Code': workType.Selected.Code,
'Type': type.Selected.Value
}
)
);
Set(
varDetail,
Patch(
'timesheetdetailpowerapps (clobotics/finance/v1.0)',
Defaults('timesheetdetailpowerapps (clobotics/finance/v1.0)'),
{
'Cause of Absence Code': cmbAbsence.Selected.Code,
'Posted Quantity': Value(txtQuantity.Text),
Type: type.Selected.Value,
Status: "Submitted"
}
)
);
If(
IsBlank(varLine),
Notify("Failed to create Timesheet Line.", NotificationType.Error),
IsBlank(varDetail),
Notify("Failed to create Timesheet Detail.", NotificationType.Error),
Notify("✅ Timesheet Line and Detail registered successfully!", NotificationType.Success)
)
timesheetdetail failed: ErrorCode: Internal_DataNotFoundFilter There is no Accounting Period within the filter.Filters: Starting Date: ..''
When I try to register hours, I get the error No Accounting Period in the Filter. I don't know how to filter. Accounting Periods exist in Business Central and are open. When I do the Hour Registration in BC with the same fields I'm using now, it's done successfully.
But not everyone who will register their hours have access to our Business Central (like external technicians etc..).
The two fields showing 8/1/2025 and unix time are fetched automatically when I choose the user and date. Both are the Accounting Period fetched for that Time Sheet.
I am a complete beginner, please heeelp :D