Saturday, October 1, 2011

Cannot submit a timesheet on the Enterprise Portal(EP) website in Microsoft Dynamics AX 2009

Hi All,

The user can create a timesheet but cannot submit a timesheet on the Enterprise Portal website, as the Submit button is not available. To be able to submit the timesheet, you have to go to the previous page of Timesheet List and then reopen the timesheet, then the Submit button appears. However, the Submit button should be available throughout timesheet entry.

As usual, I started googling for some hotfix then I found a hotfix, http://support.microsoft.com/kb/2242554 .
But this is for Timesheet Installed on the PSA Module which doesn't suit my requirement because our customer's application is with Timesheet Installed on the Projects Module then I had to edit the standard eP page and fix the issue myself.

The following will fix the issue.
The changed/extra lines of code is higlighted in Red in the following code.

Please change the following code in TSTimeSheetEdit WebControl.

protected void Page_Init(object sender, EventArgs e)


{

      InitEditableStatus(FormMode);



     // If the report isn't editable then we can skip some initialization

     if (reportEditable)

    {

        InitProjectButton();

           InitFilterTypeSelection();

AxGridViewTimesheetEditLines.RowUpdating += AxGridViewTimesheetEditLines_RowUpdating;

AxGridViewTimesheetEditLines.RowUpdated += AxGridViewTimesheetEditLines_RowUpdated;

AxGridViewTimesheetEditLines.RowDeleting += AxGridViewTimesheetEditLines_RowDeleting;

AxGridViewTimesheetEditLines.RowDeleted += AxGridViewTimesheetEditLines_RowDeleted;

AxGridViewTimesheetEditLines.RowEditing += AxGridViewTimesheetEditLines_RowEditing;



if (FormMode != ApplicationProxy.EPFormAction.CreateMode)

{

using (

IAxaptaRecordAdapter tsTimesheetTable =

ApplicationProxy.TSTimesheetTable.find(AxSession.AxaptaAdapter, TimesheetNbr))

{

if ((ApplicationProxy.TSAppStatus)tsTimesheetTable.GetField(SApprovalStatus) ==

ApplicationProxy.TSAppStatus.Returned)

{

// PanelProject.Visible = false;

}

}

}

}



InitPrintButton();



AxGridViewTimesheetEditOverview.SelectedIndexChanged += AxGridViewTimesheetEditOverview_SelectedIndexChanged;

AxGridViewTimesheetEditOverview.RowDataBound += AxGridViewTimesheetEditOverview_RowDataBound;

AxGridViewTimesheetEditOverview.PreRender += AxGridViewTimesheetEditOverview_PreRender;



AxGridViewTimesheetEditLines.RowDataBound += AxGridViewTimesheetEditLines_RowDataBound;

AxGridViewTimesheetEditLines.RowCommand += AxGridViewTimesheetEditLines_RowCommand;

AxGridViewTimesheetEditLines.PreRender += AxGridViewTimesheetEditLines_PreRender;



#region Workflow related

string fromApprove = Request.QueryString.Get(SFromApprove);



if (null != fromApprove)

{

WorkflowActionBar.Visible = false;

}

else

{

AxDataSourceWorkflowTimesheetEntry.CreatingDataSetRun += AxDataSourceWorkflowTimesheetEntry_CreatingDataSetRun;  // This is the change , Remove the comments for this line

WorkflowActionBar.EvaluatingCanSubmitToWorkflow += WorkflowActionBar_EvaluatingCanSubmitToWorkflow;

WorkflowActionBar.WorkflowSubmitCompleted += WorkflowActionBar_WorkflowSubmitCompleted;

WorkflowActionBar.WorkflowConfigurationLoading += WorkflowActionBar_WorkflowConfigurationLoading;

// MS: WorkflowActionBar.Visible = true;



if (ApprovalLevel == ApplicationProxy.TSApprovalLevel.LineItem) // Line Item Approval

{

WorkflowActionBar.DataSourceID = DsTimesheetEditLines;

WorkflowActionBar.DataMember = DmTSTimesheetLineCurrent;

}

else

{
 WorkflowActionBar.DataSourceID = DsTSWorkflowTimesheetEntry;
WorkflowActionBar.DataMember = DmTSTimesheetTableCurrent;
}
}
#endregion



#region Project Lookup related
AxLookupProjId.Lookup += AxLookupProjId_Lookup;
AxLookupProjId.OkClicked += AxLookupProjId_OkClicked;
#endregion
}

void AxDataSourceWorkflowTimesheetEntry_CreatingDataSetRun(object sender, CreatingDataSetRunEventArgs e)
{

if (TimesheetNbr != null) //Remove the comments

          e.DataSetRunArgs.parm = TimesheetNbr;//Remove the comments
}

#endregion



private IAxaptaRecordAdapter CurrentTimesheet

{

get

{

//return AxDataSourceTimesheetEditOverview.GetDataSet().DataSetViews[AxGridViewTimesheetEditOverview.DataMember].GetCurrent();

return ApplicationProxy.TSTimesheetTable.find(AxSession.AxaptaAdapter, TimesheetNbr);

}

}






private ApplicationProxy.TSAppStatus CurrentTimesheetStatus


{
get

{

ApplicationProxy.TSAppStatus timesheetStatus = (ApplicationProxy.TSAppStatus)CurrentTimesheet.GetField(SApprovalStatus);

return timesheetStatus;

}

}

No comments: