Friday 27 September 2013

contract class validation method

public boolean validate()
{

    boolean             isValid = true;

 /*  if (!fromDate)

    {

        isValid = checkFailed("From Date should be entered");

    }

    if (!toDate)

    {

        isValid = checkFailed("To Date should be entered");

    }

    if (isValid && (fromDate > toDate))

    {

        isValid = checkFailed(strfmt("From Date should be less than or equal to To Date", date2StrUsr(fromDate, DateFlags::FormatAll), date2StrUsr(toDate, DateFlags::FormatAll)));

    }


     if (!Name)

    {

        isValid = checkFailed("Name should be entered");

    }
 */

    return isValid;

}

for validation u have to write this code in contract class class delaration method
contractclassname implements SysOperationValidatable

Wednesday 25 September 2013

print report in pdf/html formate:

print report in pdf/html formate:
write the code in controlleer class





SrsReportRun srsReportRun;

    srsReportRun = new SrsReportRun("InventTruckTransactionReport.PrecisionDesign1");

    srsReportRun.init();
    srsReportRun.reportCaption("InventTruckTransactionReport.PrecisionDesign1");
    srsReportRun.reportParameter("TruckTransDS_JournalId").value("000161_070");
    srsReportRun.showDialog(false);

    // Print to a file named ReportExample in HTML/PDF format.
    srsReportRun.printDestinationSettings().printMediumType(SRSPrintMediumType::File);
    srsReportRun.printDestinationSettings().fileFormat(SRSReportFileFormat::PDF);
    srsReportRun.printDestinationSettings().overwriteFile(true);
    srsReportRun.printDestinationSettings().fileName(@"C:\InventTruckTransactionReport.pdf");

    if( srsReportRun )
    {
        srsReportRun.executeReport();
    }







for 2009 ssrs report:



static void SR_SaveReportToPDFFromController(Args _args)
{
    SalesInvoiceController  salesInvoiceController;
    SalesInvoiceContract    salesInvoiceContract;
    Args                    args = new Args();
    SrsReportRunImpl        srsReportRun;
    CustInvoiceJour         custInvoiceJour;
    ReportName              reportName = "SalesInvoice.Report";
    ;

    select firstOnly custInvoiceJour;
    args.record(custInvoiceJour);
   
    salesInvoiceController = new SalesInvoiceController();
    salesInvoiceController.parmReportName(reportName);
   
    salesInvoiceContract = salesInvoiceController.parmReportContract().parmRdpContract();
    salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
    salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo()); // comment this code if tested in pre release
    salesInvoiceController.parmArgs(args);

    srsReportRun = salesInvoiceController.parmReportRun() as SrsReportRunImpl;
   
    salesInvoiceController.parmReportRun(srsReportRun);
    salesInvoiceController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
    salesInvoiceController.parmReportContract().parmPrintSettings().overwriteFile(true);
    salesInvoiceController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
    salesInvoiceController.parmReportContract().parmPrintSettings().fileName(‘c:\\SR_SalesInvoice.pdf’);
    salesInvoiceController.runReport();
}

Saturday 14 September 2013

Jumpref method in ax 2012


[AX 2012] The table does not exist as a root FormDataSource for the form

If you are Receiving this error: “Could not process the lookupTable value on the Args instance. The table ‘TableName’ does not exist as a root FormDataSource for the form ‘TableNameForm’” I may have found a solution for you.

AX 2012 gets very angry when you call a form using a record from a datasource that is not the main form datasource. For example, if you have a form with SalesTable and SalesLine joined to it, and you call the form with a SalesLine record, this error message will pop-up. If this is for View Details, The easiest way to fix this is as follows:
1. Override the jumpRef() on the datasource field
2. Create Args and MenuFunction variables
3. Find the record for the main datasource table
4. Set args.record() to the main datasource record
5. Set menuFunction to the menu item that would be called if you went to View Details
6. Call the menu item with args
For form buttons, override the clicked() and continue following steps 2 through 6.

View Details Example:

public void jumpRef()
{
Args args = new Args();
SalesTable salesTable; // that we are using not in the datasource list or it can be
;

args.caller(this);
salesTable = SalesTable::find(SalesLine.SalesId);
Args.record(salesTable);

// Skip menuFunction declaration and run on the fly
new MenuFunction(menuitemdisplaystr(SalesTable), MenuItemType::Display).run(args); //menuitem name of that form that is to ref
}



Example:write the code in design field level :
public void jumpRef()
{
Args args = new Args();
//NetActivityTypes netActivityTypes;
;

args.caller(this);
//netActivityTypes = SalesTable::find(SalesLine.SalesId);
Args.record(netActivityTypes);

// Skip menuFunction declaration and run on the fly
new MenuFunction(menuitemdisplaystr(NetActivityTypes), MenuItemType::Display).run(args);

}

Listpage interaction class: example

Listpage interaction class:( NetReservationListPageInteraction-interaction class,
NetReservationListPage-listpage name , btnReserve-button name(autodeclaration yes),
NetReservation_NoFilter-listpage query, NetReservationTable-listpage table)


Class declaration:


public class NetReservationListPageInteraction extends ListPageInteraction
{
    smmLeadTable                smmLeadTable;
    smmActivityParentLinkTable  smmActivityParentLinkTable;

    QueryBuildRange             leadProcessRange;
    HierarchyName               selectedProcess;

    NetReservationTable         netReservationTable;
}

selectionChanged:
public void selectionChanged()
{
    super();

    this.setButtonEnabled();

     if(netReservationTable.RentalApprovalState == ApprovalState::WorkflowCompleted)// && NetReservationListPage.& NetAgreement.FinalizeAgree == NoYes::No)
      this.listPage().actionPaneControlEnabled(formControlStr(NetReservationListPage,btnReserve),true);

    else
        this.listPage().actionPaneControlEnabled(formControlStr(NetReservationListPage,btnReserve),false);



}



setButtonEnabled:

void setButtonEnabled ()
{
    boolean                 isCustomer;
    smmOpportunityTable     smmOpportunityTable;
    boolean                 enableContacts = false;
    DirOrgPersonRelations   dirOrgPersonRelations;

    netReservationTable = this.listPage().activeRecord(queryDataSourceStr(NetReservation_NoFilter, NetReservationTable));

   /* isCustomer = DirPartyTable::isCustomer(netReservationTable.Party);

    if (!netReservationTable.RecId || !netReservationTable.Party || isCustomer)
    {
        this.listPage().actionPaneControlEnabled(formControlStr(NetReservationListPage,createCustomer),false);
    }
    else
    {
        this.listPage().actionPaneControlEnabled(formControlStr(NetReservationListPage,createCustomer),true);
    }

    this.listPage().actionPaneControlEnabled(formControlStr(NetReservationListPage,customerButton),netReservationTable.RecId != 0 && isCustomer);
*/

}


setDBEnabled:

public void setDBEnabled()
{
    boolean                 isDraft;
    ;
        /*
    // DNS-Hussain on 12-09-2013

    netReservationTable = this.listPage().activeRecord(queryDataSourceStr(NetReservation_NoFilter, NetReservationTable));

    isDraft = netReservationTable.RentalApprovalState == ApprovalState::NotSubmitted;

    if(NetReservationTable.RentalApprovalState != ApprovalState::NotSubmitted)
    {
        NetReservationTable_ds.allowEdit(isDraft);
        NetReservationTable_ds.allowDelete(isDraft);
    }

    // end.

    this.setButtonEnabled();

     if(netReservationTable.RentalApprovalState == ApprovalState::WorkflowCompleted)// && NetReservationListPage.& NetAgreement.FinalizeAgree == NoYes::No)
      this.listPage().actionPaneControlEnabled(formControlStr(NetReservationListPage,btnReserve),true);

    else
        this.listPage().actionPaneControlEnabled(formControlStr(NetReservationListPage,btnReserve),false);

*/

}


Friday 6 September 2013

List page and form menuitem enable code

Listpage interaction class:

Code for Action pane button enable and disabling:
1. selectionChanged()
if(NetAgreement.Status == NetAgreementStatus::Approved && NetAgreement.FinalizeAgree == NoYes::No)
      this.listPage().actionPaneControlEnabled(formControlStr(NetAgreementList,FinalizeAgreement),true);

    else
        this.listPage().actionPaneControlEnabled(formControlStr(NetAgreementList,FinalizeAgreement),false);

2. selectionChanged()

public void selectionChanged()
{
    super();

    this.setButtonEnabled();
   
     if(netReservationTable.RentalApprovalState == ApprovalState::WorkflowCompleted)// && NetReservationListPage.& NetAgreement.FinalizeAgree == NoYes::No)
      this.listPage().actionPaneControlEnabled(formControlStr(NetReservationListPage,btnReserve),true);

    else
        this.listPage().actionPaneControlEnabled(formControlStr(NetReservationListPage,btnReserve),false);
   
   
   
}

Action pane button enabling and disabling in form:
Form –datasource-(table of data source)-active method:
1.Active():
if(NetAgreement.Status == NetAgreementStatus::Approved && NetAgreement.FinalizeAgree == NoYes::No)
      FinalizeAgreement.enabled(true);

    else
        FinalizeAgreement.enabled(false);
    //ended by poorna...04/09/2013

    return ret;

2.Active():
if(NetReservationTable.RentalApprovalState == ApprovalState::WorkflowCompleted)//&& NetAgreement.FinalizeAgree == NoYes::No)
      btnReserve.enabled(true);
    else
        btnReserve.enabled(false);



Wednesday 4 September 2013

WorkFlow in ax 2012 (Latest) org

Work Flow in AX-2012 steps:

Steps:
First create one enum type (approval state)
One table having(Ex: WFTable)
Enum field
Submitted by field
Submitted date field
//And one edt field(NA)
Here in that table 5 methods mandatory
1.Find():
public static WFTable find(Name    Name, boolean _forupdate = false)
{
    WFTable WFTable;//        leaveRequests;
;
    WFTable.selectForUpdate(_forupdate);

    if(Name)
    {
        select WFTable
            where WFTable.Name == Name;
    }

    return WFTable;
}

2.findRecId():
static WFTable findRecId(RecId    _recId,
                           boolean  _forUpdate = false)
{
    WFTable WFTable;
    ;

    if (_recId)
    {
        WFTable.selectForUpdate(_forUpdate);

        select firstonly WFTable
            where WFTable.RecId == _recId;
    }
    return WFTable;
}


3.can submit():
public boolean canSubmit()
{
;
    if(this.WFEnabled == ApprovalState::NotSubmitted  && this.RecId)
        return true;
    else
        return false;
}

4.cansubmittedworkflow():
Display boolean CanSubmitToWorkFlow(str _workflowtype =  '')
{
 return this.canSubmit();
}

5.UpdateWorkflowState ():
public static void UpdateWorkflowState(RefRecId _recId, ApprovalState _state)
    {
        WFTable WFTable = WFTable::findRecId(_recId, true);
         //Vacations       vacations;
        ttsBegin;

        //if(WFTable.IsWorkflowToBeResubmitted)
           // nsgLeaveRequests.IsWorkflowToBeResubmitted = false;
        WFTable.WFEnabled = _state;

        /*nsgLeaveRequests.update();
       //Commented and added by Britto on 16/10/2012
       // if(nsgLeaveRequests.WorkflowState == WFDummiesWorkflowState::Approved && SystemSetup::find().AutomaticVacationTransfromEP)

       if(nsgLeaveRequests.WorkflowState == NSGLeaveReqWorkflowState::ApprovedII )
        {
         /*   Vacations::CreateFromEPLeaveRequest(nsgLeaveRequests.LeaveRequestId,
                                                nsgLeaveRequests.EmplId,
                                                nsgLeaveRequests.VacationType,
                                                nsgLeaveRequests.LeaveFrom,
                                                nsgLeaveRequests.LeaveTo,
                                                NASVacationInitiateType::FormRequest,
                                                nsgLeaveRequests.Destination);*/



            //nsgLeaveRequests.VacationTransId =Vacations::CreateFromEPLeaveReq(nsgLeaveRequests);

            nsgLeaveRequests.Comments += "\n" + "Final Approval" +"\n" + nsgLeaveRequests.mostRecentComment();

        }
          if(nsgLeaveRequests.WorkflowState == NSGLeaveReqWorkflowState::ApprovedII )
        {
                  nsgLeaveRequests.Comments += "\n" + "HR Dept Comments" +"\n" + nsgLeaveRequests.mostRecentComment();
        }
           if(nsgLeaveRequests.WorkflowState == NSGLeaveReqWorkflowState::Approved )
        {
              nsgLeaveRequests.Comments += "\n" + "Dept Head Comment" +"\n" + nsgLeaveRequests.mostRecentComment();
        }
        */
          WFTable.update();
        ttsCommit;
   }


Then next Create a qury and add data sorce as our table
And then create form and desighn the form
Here in design properties set this three property as mandatory
(Workflow enabled-yes
Workflow datsource-ourtable name
Workflow type- our workflow type             ::this properties are set in last)

And then go to AOT:
1.Create workflow category-  R.C properties – here select module name(in which module ur working)
2.workflow type-rc-addins –create workflow type through wizard
Set properties as:
Name- name of workflow type
Category- name of our category type
Query- name of query which u created
 Document Menuitem- name of form or list page menuitem(in which form or list page ur showing the list page status)
Document web menu item –NA
Generate menu item –Rich client
//(no need to give field groups)
3.approval- rc-addins –create workflow Approval through wizard
Set properties as:
Name- approval name
Workflow document- document item name
Document preview field group-no need to give
Document menu item- our form or list page menu item name
Document web menu item- na
Generate menu item-rich client
Enable deny outcome-na
4. I f we need task also same R.c-on task-addins – generate task wizard-here also set the propertis
Then drag in toworkflow type supported items like as approval
Name-name of the task
Workflow document- document item name
Document preview field group-no need to give
Document menu item- our form or list page menu item name
Document web menu item- na
Generate menu item-rich client


Then click next above window opens
Here we add two things one returned and completed then next click ok



5. Incremental CIL
6. drag the approval and task(first) to our workflow type supported element
And then


Write code in classes:
WFApprEventHandler():

Classdeclaratio():
class WFApprEventHandler implements    WorkflowElementCanceledEventHandler,  WorkflowElemChangeRequestedEventHandler,
                                                        WorkflowElementCompletedEventHandler, WorkflowElementReturnedEventHandler,
                                                        WorkflowElementStartedEventHandler, WorkflowElementDeniedEventHandler,
                                                        WorkflowWorkItemsCreatedEventHandler
{
}

Canceled():
public void canceled(WorkflowElementEventArgs _workflowElementEventArgs)
{
     WFTable::UpdateWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), ApprovalState::Cancelled);
}

changeRequested():
public void changeRequested(WorkflowElementEventArgs _workflowElementEventArgs)
{
    WFTable::UpdateWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), ApprovalState::ChangeRequest);
}

Completed():
public void completed(WorkflowElementEventArgs _workflowElementEventArgs)
{
    WFTable::UpdateWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), ApprovalState::Approved);
}




created ():
public void created(WorkflowWorkItemsEventArgs _workflowWorkItemsEventArgs)
{
    // TODO:  Write code to execute once work items are created.
}


denied ():
public void denied(WorkflowElementEventArgs _workflowElementEventArgs)
{
   WFTable::UpdateWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), ApprovalState::Returned);
}



returned ():
public void returned(WorkflowElementEventArgs _workflowElementEventArgs)
{
    WFTable::UpdateWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), ApprovalState::Returned);
}

Started():
public void started(WorkflowElementEventArgs _workflowElementEventArgs)
{
    WFTable::UpdateWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), ApprovalState::PendingApproval);
}


WFTypeEventHandler():

Classdeclaration():

class WFTypeEventHandler implements    WorkflowCanceledEventHandler,  WorkflowCompletedEventHandler,
                                                        WorkflowStartedEventHandler
{
}

Canceled():
public void canceled(WorkflowEventArgs _workflowEventArgs)
{
    WFTable::UpdateWorkflowState(_workflowEventArgs.parmWorkflowContext().parmRecId(), ApprovalState::Cancelled);
}


completed ():
public void completed(WorkflowEventArgs _workflowEventArgs)
{
    WFTable::UpdateWorkflowState(_workflowEventArgs.parmWorkflowContext().parmRecId(), ApprovalState::WorkflowCompleted);
}


started ():
public void started(WorkflowEventArgs _workflowEventArgs)
{
    WFTable::UpdateWorkflowState(_workflowEventArgs.parmWorkflowContext().parmRecId(), ApprovalState::Submitted);
}





WFTypeSubmitManager():

Classdeclaration():
public class WFTypeSubmitManager
{
    Name                        Name;
    WFTable                     WFTable;
    WorkflowVersionTable        workflowConfigurationTable;
    WorkflowComment             workflowComment;
    boolean                     submit;
    WorkflowWorkItemTable       workflowWorkItemTable;
    UserId                      userId;
    MenuItemName                menuItemName;
    WorkflowTypeName            workflowTemplateName;
    EPWorkflowControlContext    workflowControlContext;
}

dialogOk():

public boolean dialogOk()
{
    WorkflowSubmitDialog workflowSubmitDialog;
    WorkflowWorkItemActionDialog workflowWorkItemActionDialog;

    boolean ok;
    ;
    if (menuItemName == menuitemactionstr(WFTypeSubmitMenuItem))
    {
        workflowSubmitDialog = WorkflowSubmitDialog::construct(this.parmWorkflowConfigurationTable());
        workflowSubmitDialog.run();
        this.parmWorkflowComment(workflowSubmitDialog.parmWorkflowComment());
        ok = workflowSubmitDialog.parmIsClosedOK();
    }
    else if (menuItemName == menuitemactionstr(WFApprResubmitMenuItem))
    {
        workflowWorkItemActionDialog = WorkflowWorkItemActionDialog::construct( workflowWorkItemTable,
        WorkflowWorkItemActionType::Resubmit,
        new MenuFunction(menuitemactionstr(WFApprResubmitMenuItem), MenuItemType::Action));
        workflowWorkItemActionDialog.run();
        this.parmWorkflowComment(workflowWorkItemActionDialog.parmWorkflowComment());
        ok = workflowWorkItemActionDialog.parmIsClosedOK();
        userId = workflowWorkItemActionDialog.parmTargetUser();
    }
    return ok;
}


Init():
public void init( Common _documentRecord,
                    MenuItemName _menuItemName,
                    WorkflowVersionTable _workflowConfigurationTable,
                    WorkflowWorkItemTable _workflowWorkItemTable,
                    EPWorkflowControlContext _workflowControlContext
                    )
{
    this.parmWFTable(_documentRecord);
    this.parmSubmit(_menuItemName == menuitemactionstr (WFTypeSubmitMenuItem));
    this.parmMenuItemName(_menuItemName);
    if (_workflowControlContext)
    {
        this.parmWorkflowControlContext(_workflowControlContext);
        this.parmWorkflowWorkItemtable (_workflowControlContext.getActiveWorkflowWorkItem());
        this.parmWorkflowComment(_workflowControlContext.getWorkflowComment());
        this.parmWorkflowTemplateName (_workflowControlContext.getActiveWorkflowConfiguration().WorkflowTable().TemplateName);
    }
    else
    {
        this.parmWorkflowConfigurationTable(_workflowConfigurationTable);
        this.parmWorkflowWorkItemtable(_workflowWorkItemTable);
        this.parmWorkflowTemplateName (this.parmWorkflowConfigurationTable().WorkflowTable().TemplateName);
    }


}

parmMenuItemName():
public MenuItemName parmMenuItemName(MenuItemName _menuItemName = menuItemName)
{
    ;
    menuItemName = _menuItemName;
    return menuItemName;
}


parmSubmit ():
public boolean parmSubmit(boolean _submit = submit)
{
;
submit = _submit;
return submit;
}

parmWFTable():
public WFTable parmWFTable(WFTable _WFTable = WFTable)
{
    ;
    WFTable = _WFTable;
    return WFTable;
}

parmWorkflowComment():
public WorkflowComment parmWorkflowComment(WorkflowComment _workflowComment = workflowComment)
{
;
workflowComment = _workflowComment;
return workflowComment;
}

parmWorkflowConfigurationTable():
public WorkflowVersionTable parmWorkflowConfigurationTable(WorkflowVersionTable _workflowConfigurationTable = workflowConfigurationTable)
{
;
workflowConfigurationTable = _workflowConfigurationTable;
return workflowConfigurationTable;
}

parmWorkflowControlContext():
public EPWorkflowControlContext parmWorkflowControlContext(EPWorkflowControlContext _workflowControlContext = workflowControlContext)
{
;
workflowControlContext = _workflowControlContext;
return workflowControlContext;
}

parmWorkflowTemplateName():
public WorkflowTypeName parmWorkflowTemplateName(WorkflowTypeName _workflowTemplateName = workflowTemplateName)
{
;
workflowTemplateName = _workflowTemplateName;
return workflowTemplateName;
}

parmWorkflowWorkItemtable():
public WorkflowWorkItemTable parmWorkflowWorkItemtable(WorkflowWorkItemTable _workflowWorkItemTable = workflowWorkItemTable)
{
;
workflowWorkItemTable = _workflowWorkItemTable;
return workflowWorkItemTable;
}

reSubmit():
private void reSubmit()
{
    Object WFTable_ds;
    NoYes                   reSubmittingFromWeb;

    // If we have a workflow control context, we are being resubmitted from EP
    reSubmittingFromWeb = this.parmWorkflowControlContext() == null ? NoYes::No : NoYes::Yes;
    ttsbegin;

    WorkflowWorkItemActionManager::dispatchWorkItemAction( workflowWorkItemTable, workflowComment, userId, WorkflowWorkItemActionType::Resubmit, menuItemName, false);
    WFTable_ds = WFTable.dataSource();
    WFTable = WFTable::findRecId(WFTable.RecId, true);

    WFTable.WFEnabled = ApprovalState::Submitted;
    WFTable.doUpdate();
    if (WFTable_ds)
    {
        WFTable_ds.write();
        WFTable_ds.refresh();
    }
    ttscommit;
}

submit():
private void submit()
{
    Object WFTable_ds;
    NoYes activatingFromWeb;
    ;
    // If we have a workflow control context, we are being activated from EP
    activatingFromWeb = this.parmWorkflowControlContext() == null ? NoYes::No : NoYes::Yes;

    ttsBegin;
    Workflow::activateFromWorkflowType( this.parmWorkflowTemplateName(),WFTable.RecId, this.parmWorkflowComment(),activatingFromWeb, curuserid());
    WFTable_ds = WFTable.dataSource();
    WFTable = WFTable::findRecId(WFTable.RecId, true);
    WFTable.SubBy = curuserid();
  //  WFTable.SubDate = utcDateTime2SystemDateTime(DateTimeUtil::utcNow());
    WFTable.WFEnabled = ApprovalState::Submitted;
    WFTable.doUpdate();
    if (WFTable_ds)
    {
        WFTable_ds.write();
        WFTable_ds.reread();
        WFTable_ds.refresh();
    }
    ttsCommit;
}

construct():
public static WFTypeSubmitManager construct()
{
    return new WFTypeSubmitManager();
}



Main():
public static void main(Args args)
{
    WFTypeSubmitManager WFTypeSubmitManager;
    //EmplContract EmplContract;
    WFTable           WFTable;
     // Variable declaration.
    recId recId;
    WorkflowCorrelationId workflowCorrelationId;
    Object                          callerDataSource;

    // Hardcoded workflow type name
    workflowTypeName workflowTypeName = workflowtypestr("WFType");

    // Initial note is the information that users enter when they
    // submit the document for workflow.
    WorkflowComment initialNote = "Enter any comments here.";
    WorkflowSubmitDialog workflowSubmitDialog;

    // The name of the table containing the records for workflow.
    FormDataSource   WFTable_ds;

    // Workflow Control Context
    EPWorkflowControlContext workflowControlContext;

    ;
    WFTable = args.record();
    WFTypeSubmitManager = WFTypeSubmitManager::construct();
    if (args.menuItemName() == menuitemactionstr(WFTypeSubmitMenuItem) ||
        args.menuItemName() == menuitemactionstr(WFApprResubmitMenuItem))
    {
        WFTypeSubmitManager.init(args.record(), args.menuItemName(), args.caller().getActiveWorkflowConfiguration(), args.caller().getActiveWorkflowWorkItem(),null);
    }
    else
    {
        WFTypeSubmitManager.init(args.record(), args.menuItemName(), nullnull, args.caller());
    }

    if (WFTypeSubmitManager.dialogOk())
    {
            if (WFTypeSubmitManager.parmSubmit())
            {
                WFTypeSubmitManager.submit();
            }
            else
            {
                WFTypeSubmitManager.reSubmit();
            }

            if (args.menuItemName() == menuitemactionstr(WFTypeSubmitMenuItem) ||
                args.menuItemName() == menuitemactionstr(WFApprResubmitMenuItem))
                    args.caller().updateWorkflowControls();
    }



    if (!webSession())
    {
        callerDataSource = args.record().dataSource();
        if (callerDataSource)
        {
            callerDataSource.research(true);
        }

        args.caller().updateWorkflowControls();
    }

}

WFTaskEventHandler:

Classdeclaration() :

class DN_ReserveTaskEventHandler implements    WorkflowElementCanceledEventHandler,  WorkflowElemChangeRequestedEventHandler,
                                                        WorkflowElementCompletedEventHandler, WorkflowElementReturnedEventHandler,
                                                        WorkflowElementStartedEventHandler, WorkflowElementDeniedEventHandler,
                                                        WorkflowWorkItemsCreatedEventHandler
{
}

Canceled();

public void canceled(WorkflowElementEventArgs _workflowElementEventArgs)
{
    /// TODO:  Write code to execute once the workflow is canceled.
}

changeRequested();

public void changeRequested(WorkflowElementEventArgs _workflowElementEventArgs)
{
    /// TODO:  Write code to execute once change is requested for the workflow.
}

Completed():

public void completed(WorkflowElementEventArgs _workflowElementEventArgs)
{
    WFTable::UpdateWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(),ApprovalState::TaskCompleted);
}

Created():

public void created(WorkflowWorkItemsEventArgs _workflowWorkItemsEventArgs)
{
    /// TODO:  Write code to execute once work items are created.
}

Denied():

public void denied(WorkflowElementEventArgs _workflowElementEventArgs)
{
    /// TODO:  Write code to execute once the workflow is denied.
}

Returned():

public void returned(WorkflowElementEventArgs _workflowElementEventArgs)
{
    WFTable::UpdateWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(),ApprovalState::Returned);

}
Started():

public void started(WorkflowElementEventArgs _workflowElementEventArgs)
{
 WFTable::UpdateWorkflowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(),ApprovalState::TaskStarted);
}





After that go to the module where u r working then go to area page-setup-workflow configuration

Click on that

Create new- select what u crated

Here u create flow diagram
Here give the
Basic settings
Assignment-user for task to ur id(only u)
Assignment-user for approval to approval persons (one r many)
Here we give the completion policy(for approval)-single approver
Here we give the time limit for approval(default r check all days)