Showing posts with label SysOperation. Show all posts
Showing posts with label SysOperation. Show all posts

Monday, April 18, 2022

Hide the Batch tab in SysOperation dialog in both D365 & AX2012

Written the below code in controller class.

Way 1:

public static void main(Args args) {

    controller.parmShowDialog(false);//Hide the batch dialog

    controller.showBatchTab(false);//Hide the batch tab in dialog

    
    //controller.captionIsSet = false;

// controller.parmDialogCaption(isExcelUp ? "ExcelUpload" :"Manual");

}

Way 2:

public void postRun() { SysOperationDialog sysOperationDialog; DialogTabPage dialogTabPage; FormRun formRun; super(); sysOperationDialog = this.dialog() as SysOperationDialog; formRun = sysoperationDialog.formRun(); dialogTabPage = sysOperationDialog.batchDialogTabPage(); formRun.control(formRun.controlId(dialogTabPage.name())).enabled(false); }


Keep Daxing!!

Tuesday, February 22, 2022

Get selected records in grid from caller data source in sys operation in D365FO.

Hi guys, Today we see how how to get the selected records from grid in sys operation using x++ in D365FO. 

Just check below code. Main code I have written in controller class.


Contract class: 

[DataContractAttribute] public class TestrContract { List refRecId; [ DataMemberAttribute("refRecID"), AifCollectionTypeAttribute("_refRecID", Types::Int64), SysOperationControlVisibilityAttribute(false)// Hide control ] public List parmrefRecID(List _refRecID = refRecID) { refRecID = _refRecID; return refRecID; } } ---------------------------------------------------------------------------

Controller class:  class TestController extends SrsReportRunController { public void new() { /*super(classStr(TestSysOperationService), methodStr(TestSysOperationService, process), SysOperationExecutionMode::Synchronous);*/ super(); this.parmClassName(classStr(TestSysOperationService)); this.parmMethodName(methodStr(TestSysOperationService, process)); this.parmDialogCaption("Dialog Title"); } public ClassDescription caption() { return "Task Description"; } public static void main(Args _args) { TestController controller = new TestSysOperationController();

        //controller.captionIsSet = false;    // controller.parmDialogCaption(isExcelUp ? "ExcelUpload" :"Manual"); controller.initFromCaller(); controller.refreshCallerRecord(); controller.startOperation(); } private void initFromCaller() { TestCustomer testCustomerLoc; FormDataSource testCustomer_DS; TestrContract contract; List myList; #define.dataContractKey('_contract') contract = this.getDataContractObject(#dataContractKey) contract.parmCallerTableId(this.parmCallerRecord().TableId); if(this.parmargs().dataset() == tableNum(TestCustomer)) { testCustomer_DS = FormDataUtil::getFormDataSource(this.parmCallerRecord()); myList = new List(Types::Int64); for (testCustomerLoc = getFirstSelection(testCustomer_DS); testCustomerLoc; testCustomerLoc = testCustomer_DS.getNext()) { myList.addStart(testCustomerLoc.RecId); } contract.parmrefRecID(myList); } } --------------------------------------------------------------------------------------

Service Class : public class TestSysOperationServiceClass extends SysOperationServiceBase { public void process(TestContractClass _contract) { info("Running"); List list = _contract.parmVendorList(); ListEnumerator enumerator = list.getEnumerator(); while(enumerator.moveNext()) { // your code. Info(strFmt('%1- recid', enumerator.current()); } } }


If u need for report please check my old post.

Get Multi records in report


Keep Daxing!!

Tuesday, February 15, 2022

Multithread in sysoperation framework in D365FO

 Hi guys, Today we see the multithread in sys operation. For sys operation we required 4 classes.

Here we need to create two more classes.

1. Controller class.

2. Service class.

From controller class we need to call service class like the same of sys operation. In service class we need to apply group in our table based on requirement and we are using standard classes to send our value to our contract and controller class.

For multithread Controller class we need to create action menu item.

Just check below code.

Multithread Controller class: 

class TestMultiThreadController extends SysOperationServiceController { public ClassDescription defaultCaption() { return 'order creation using multithread'; } public static void main(Args args) { TestMultiThreadController controller = new TestMultiThreadController(); controller.startOperation(); } public void new() { //super(classStr(TestMultiThreadService), //methodStr(TestMultiThreadService, processOperation), //SysOperationExecutionMode::Synchronous); super(); this.parmClassName(classStr(TestMultiThreadService)); this.parmMethodName(methodStr(TestMultiThreadService, processOperation)); this.parmDialogCaption("Batch operation"); } }

--------------------------------------------------------------------------

Multithread Service Class :


class TestMultiThreadService extends SysOperationServiceBase { public void processOperation()//TestContract _contract) { TestCustomer testCustomer;//My table TestMyController controller;//my controller TestMyContract contract;//my contarct BatchHeader batchHeader; BatchInfo batchInfo; SysRecurrenceData sysRecurrenceData = SysRecurrence::defaultRecurrence(); batchHeader = BatchHeader::construct(); controller = new TestMyController(); while select testCustomer group by Filename // 'Filename' my custom field. where testCustomer.Processed == NoYes::No && testCustomer.ErrorInRecord == NoYes::No { sysRecurrenceData = sysRecurrence::setRecurrenceEndAfter(sysRecurrenceData, 1); batchInfo         = controller.batchInfo(); batchInfo.parmCaption(strFmt("order creation for File- %1", testCustomer.FileName)); contract = controller.getDataContractObject();//get my contract class. contract.parmFileName(testCustomer.FileName);// passing my field value. batchHeader.addTask(controller);//Passing my cotroller to the batch. batchHeader.parmRecurrenceData(sysRecurrenceData); batchHeader.save(); } } }

Keep Daxing!!

Tuesday, December 21, 2021

How to add Records to include option on sys operation dialog in D365FO

 Hi guys, Today we see how to add records to include option to sys operation.




While running the batch we have to filter the data based on requirements. Instead of writing while loops. We can use query. Just follow the below steps.


Step 1: Create a static query and add data sources based on your requirement. Here I have added Vendatable.


Required fields drag to Ranges node those will be displayed in the dialog.

Sometimes we need the same data from the query. Instead of selecting the values from the front end, we can define in value property.



Step 2: Create a Contract class, add parm methods for your parameters and we have to add a few methods to get that option.

[DataContractAttribute] class TestSysOperationContract { Name name; str packedQuery; [DataMemberAttribute] public Name parmName(Name _name = name) { name = _name; return name; }

    //SysOperationControlVisibilityAttribute(false)// Hide control

[DataMemberAttribute, AifQueryTypeAttribute('_packedQuery', querystr(TestVendorQuery)) ] public str parmQuery(str _packedQuery = packedQuery) { packedQuery = _packedQuery; return packedQuery; } public Query getQuery() { return new Query(SysOperationHelper::base64Decode(packedQuery)); } public void setQuery(Query _query) { packedQuery = SysOperationHelper::base64Encode(_query.pack()); } //public void initQuery() //{ // Query query = new Query(querystr(TestVendorQuery)); // this.setQuery(query); //} }

Step 3: Create a Controller class for calling the service class.

class TestSysOperationController extends SysOperationServiceController
{
    public static void main(Args args)
    {
        TestSysOperationController      controller;
        ;

        controller =  new TestSysOperationController();
        controller.startOperation();
    }
    public void new()
    {
        super(classStr(TestSysOperationService),
                methodStr(TestSysOperationService, process));//,
                    //  SysOperationExecutionMode::Synchronous);
        this.parmDialogCaption("Dialog Title");
    }
} 

Step 4: Create a service class to write our business logic.

class TestSysOperationService extends SysOperationServiceBase
{
    //[SysEntryPointAttribute]
    public void process(TestSysOperationContract _contract)
    {
        QueryRun    queryRun;
        VendTable   vendTable;
        ;

        // create a new queryrun object
        queryRun = new queryRun(_contract.getQuery());

        while(queryRun.next())
        {
            vendTable = queryRun.get(tableNum(VendTable));
            // Your logic.
            info(strFmt('Account - %1 , Name - %2',vendTable.AccountNum,vendTable.name()));
        }
    }

} 

Ends.............

------------------------------------------------------------------------

Sys operation :

If we need to run this batch based on the caller record.


We need to change the logic in the Controller class.

class TestSysOperationController extends SysOperationServiceController { public static void main(Args args) { TestSysOperationController controller; ; controller = TestSysOperationController::newFromArgs(args); controller.startOperation(); } public static TestSysOperationController newFromArgs(Args _args) { TestSysOperationController testController; TestSysOperationContract contract; testController = new TestSysOperationController(); //controller.initializeFromArgs(_args); //contract.initQuery(); if(_args && _args.dataset() == tableNum(VendTable)) { VendTable vendTable; Query query;

            //controller.getDataContractObject()//// for sys operation             //controller.parmReportContract().parmRdpContract() // For Report
contract = testController.getDataContractObject('_contract');
                      // '_contract' this name is from service class method parameter buffer. vendTable = _args.record(); if (vendTable) { query = new query(queryStr(TestVendorQuery));                 //query = contract.getQuery();
//query.clearQueryFilters(); query.dataSourceTable(tableNum(VendTable)).clearRanges(); query.dataSourceTable(tableNum(VendTable)).addRange(fieldNum(VendTable, VendGroup)).value(queryValue(vendTable.VendGroup)); query.dataSourceTable(tableNum(VendTable)).addRange(fieldNum(VendTable, AccountNum)).value(queryValue(vendTable.AccountNum)); contract.setQuery(query); } } return testController; } public void new() { super(classStr(TestSysOperationService), methodStr(TestSysOperationService, process));//, // SysOperationExecutionMode::Synchronous); this.parmDialogCaption("Dialog Title"); } }

multiple records
protected void initContract(Args _args)
{
    MyContract   contract;
    Query        q;
    ;
    contract = this.getDataContractObject('_contract'); 
    q = contract.getQuery();
    
    MultiSelectionHelper multiSelectionHelper;

    multiSelectionHelper = MultiSelectionHelper::createFromCaller(_args.caller());
    multiSelectionHelper.createQueryRanges(q.dataSourceTable(tableNum(MyTable)), 
                                                        fieldStr(MyTable, JournalId));
    
    qbr = findOrCreateRange_W(q.dataSourceTable(tableNum(MyTable)), 
                                                        fieldNum(MyTable, JournalId));

    contract.setQuery(q);
}





Keep daxing!!





Friday, November 12, 2021

SysOperation without using controller class in d365fo.

 We can run the batch using sys operation frame work. we can use sys operation without using controller class.


I created a service class and I wrote the logic. After I created an action menu item and I mentioned below properties.


TestSysOperationServiceClass is my service class and process is my service class method.

Keep Daxing!!

SysOperation in D365fo

 Topic : SysOperation /Batch Processing in D365fo.

Instead of the RunBase framework, we can use the SysOperation framework. It contains 4 classes. Based on requirements we can use the required classes.

Controller class: 

    This class is the main class. Here we are calling service class and we can call contract also.

    public class TestSysOperationController extends SysOperationServiceController { public void new() { //super(classStr(TestSysOperationService), methodStr(TestSysOperationService, process), SysOperationExecutionMode::Synchronous); super(); this.parmClassName(classStr(TestSysOperationService)); this.parmMethodName(methodStr(TestSysOperationService, process)); this.parmDialogCaption("Dialog Title"); } public ClassDescription caption() { return "Task Description"; } public static void main(Args args) { TestSysOperationController controller; controller = new TestSysOperationController(); //controller = TestSysOperationController::construct();

            //controller.parmShowDialog(false);//Hide the batch dialog

            //controller.initFromCaller()//Get contract class

            //controller.refreshCallerRecord()//Refresh caller data source

            //controller.captionIsSet = false;

       // controller.parmDialogCaption(isExcelUp ? "ExcelUpload" :"Manual");

controller.startOperation();    

            //controller.getDataContractObject()//// for sys operation     //controller.parmReportContract().parmRdpContract() } public static TestSysOperationController construct(SysOperationExecutionMode _executionMode = SysOperationExecutionMode::Synchronous) { TestSysOperationController controller; controller = new TestSysOperationController(); controller.parmExecutionMode(_executionMode); return controller;

        /*ClassName className; MethodName methodName; switch (_args.menuItemName()) { // It will trigger change whs process in site locations case menuItemActionStr('Action menu item name') : className = classStr(Service); methodName = methodStr(Service, process); break; default: break; } return new TestSysOperationController(className, methodName);*/ }

        private void initFromCaller()     {     HelperContract contract;     #define.dataContractKey('_contract')     contract = this.getDataContractObject(#dataContractKey)     contract.initialize();     contract.parmCallerTableId(this.parmCallerRecord().TableId);     }

        protected void refreshCallerRecord()     {

            FormDataSource    callerDataSource; 

          callerDataSource = FormDataUtil::getFormDataSource(this.parmCallerRecord());

    if (this.parmCallerRecord() && callerDataSource)     {     callerDataSource.reread();     callerDataSource.research(true);     callerDataSource.refresh();     }     }

}

--------------------------------------------------------------------------

Service Class :

Our business logic is written here and this class is called from the controller class.

public class TestSysOperationServiceClass extends SysOperationServiceBase { public void process(TestContractClass _contract) { info(‘Running’); List list = _contract.parmVendorList(); }

}

------------------------------------------------------------------------

Contract Class :

This class is used to create the parm methods If any parameters are required in the dialog.

[ DataContractAttribute, SysOperationContractProcessingAttribute(classstr(TestUIBuilderClass)) ] class TestContractClass { List vendAccountList; [ DataMemberAttribute("Vendor"), AifCollectionTypeAttribute("Vendor", Types::String), SysOperationLabelAttribute(literalstr("Vend account")), SysOperationHelpTextAttribute(literalstr("Vend account.")), //SysOperationGroupMemberAttribute('Group'), SysOperationDisplayOrderAttribute('1')

//SysOperationControlVisibilityAttribute(false)// Hide control ] public List parmVendorList(List _vendAccountList = vendAccountList) { vendAccountList = _vendAccountList; return vendAccountList; }

}

-------------------------------------------------------------------------------------------------------------

UI Builder Class:

This class is used to lookup, jumpref, modified, validate methods for dialog controls. we can add groups in that dialog. This is mainly for dialog design changes.

    class TestUIBuilderClass extends SysOperationAutomaticUIBuilder//SrsReportDataContractUIBuilder { TestContractClass myContractClass; DialogField dialogField; container con; public void build() { // super(); // Add group to dialog //Dialog dialogObject = this.dialog(); // dialogObject.addGroup('Group'); myContractClass = this.dataContractObject() as TestContractClass; dialogField = this.addDialogField(methodStr(TestContractClass,                                       parmVendorList), TestContractClass);

} public void postBuild() //or postRun() we can use any method. { super(); myContractClass = this.dataContractObject() as TestContractClass; dialogField = this.bindInfo().getDialogField(TestContractClass,                                                 methodStr(TestContractClass, parmVendorList));

dialogField.registerOverrideMethod(methodStr(FormStringControl, lookup),                             methodStr(TestUIBuilderClass, VendorLookup), this);

//dialogField.registerOverrideMethod(methodStr(FormStringControl, modified),                       methodStr(TestUIBuilderClass, Vendormodified), this); // modified method.

//dialogField.registerOverrideMethod(methodStr(FormStringControl, validate),                     methodStr(TestUIBuilderClass, vendorValidate), this); // validate method.

//if (dialogField) //{ // dialogField.lookupButton(2); //} } public boolean vendorValidate(FormStringControl _control) { if(!VendTable::Exist(_control.Value())) { error("Selected Vendor is not exists"); return false; } return true; } public void VendorLookup(FormStringControl _control) { Query query = new Query(); QueryBuildDataSource vendQBD; // QueryBuildFieldList fieldList; vendQBD = query.addDataSource(tableNum(VendTable)); //qbds1 = qbds.addDataSource(tableNum(DirPartyTable)); //qbds1.relations(True); //qbds1.fields().clearFieldList(); //fieldList = qbds.fields(); //fieldList.addField(fieldNum(DirPartyTable, Name)); //fieldList.dynamic(QueryFieldListDynamic::No); vendQBD.addSelectionField(fieldNum(VendTable, AccountNum)); SysLookupMultiSelectGrid::lookup(query, _control, _control, _control, con); } }


Keep Daxing!!

Friday, June 11, 2021

Cannot stop DynamicsAxBatch service on computer Dynamics 365Fo

 Cannot stop DynamicsAxBatch service on computer Dynamics 365Fo.

1. Stop DynamicsAxBatch from services.

If it throw's any error. use below steps.


Open CMD with run as administrator and run the below command.


"sc queryex DynamicsAxBatch"



Get the PID number from above screen shot. and run below command.

“taskkill /f /pid [pid number]”

EX : taskkill /f /pid 000.

After this buid you're system or project.


Keep Daxing!!


Monday, December 7, 2020

ADD Lookup, Disable Dialog field using UI builder in D365FO/Ax7


 Hi guys, Today we see how to ADD Lookup, Disable Dialog field using UI builder in D365FO/Ax7.


UiBuilder Class:

class PriceDiscUiBuilder extends             SysOperationAutomaticUIBuilder //SrsReportDataContractUIBuilder

{

    PriceDiscDataContract priceDiscDataContract;

 

    Public void build()

    {

        priceDiscDataContract = this.dataContractObject();

        this.addDialogField(methodStr(PriceDiscDataContract, parmPriceDiscJournalNum), priceDiscDataContract).allowEdit(false);// Disable the field

        this.addDialogField(methodStr(PriceDiscDataContract, parmPostedPriceDiscJournalNum ), priceDiscDataContract);

    }


    Public void lookupPostJour(FormStringControl _formStringControl)

    {

        Query                   query = new Query();

        QueryBuildDataSource    qbds;

        QueryBuildRange         qbr;

        SysTableLookup          lookup;


        lookup = SysTableLookup::newParameters(tableNum(PriceDiscAdmTable), _formStringControl);


        qbds=query.addDataSource(tableNum(PriceDiscAdmTable));

        qbr=qbds.addRange(fieldNum(PriceDiscAdmTable, Posted));

        qbr.value(SysQuery::value(NoYes::Yes));

        lookup.parmQuery(query);


        lookup.addLookupfield(fieldNum(PriceDiscAdmTable, JournalNum));

        lookup.addLookupfield(fieldNum(PriceDiscAdmTable, JournalName));

        lookup.performFormLookup();

    }


    Public void PostBuild()

    {

        DialogField postedJourNum;


        postedJourNum=this.bindInfo().getDialogField(this.dataContractObject(),

                                            methodStr(PriceDiscDataContract,parmPostedPriceDiscJournalNum));

        postedJourNum.registerOverrideMethod(methodStr(FormStringControl, lookup),

                                            methodStr(PriceDiscUiBuilder, lookupPostJour), this);

    }

}


Contract Class:


[DataContractAttribute,

    SysOperationContractProcessingAttribute(classstr(PricediscUiBuilder))]

public class PriceDiscDataContract

{

    str                     priceDiscJournalNum;

    PriceDiscJournalNum     postedPriceDiscJournalNum;

 

    [DataMemberAttribute,

    sysoperationh('Current journal number'),

    SysOperationHelpTextAttribute('Enter journal number')]

//SysOperationControlVisibilityAttribute(false)// Hide control

    public str parmPriceDiscJournalNum(str _priceDiscJournalNum = priceDiscJournalNum)

    {

        priceDiscJournalNum = _priceDiscJournalNum;

        return priceDiscJournalNum;

    }


    [DataMemberAttribute,

    SysOperationLabelAttribute('Posted journal number'),

    SysOperationHelpTextAttribute('Enter journal number')]

    public PriceDiscJournalNum parmPostedPriceDiscJournalNum(PriceDiscJournalNum _priceDiscJournalNum = postedPriceDiscJournalNum)

    {

        postedPriceDiscJournalNum = _priceDiscJournalNum;

        return postedPriceDiscJournalNum;

    }

}

OutPut:

Keep Daxing!!




Passing Values to Data contract class in AX7/ D365 fo

 

Hi guys, Today we see how to Pass Values to Data contract class in AX7/ D365 fo.


I am passing the values from 'From Clicked method' to 'Data contract class' by Controller Class. 

Check the below example:


void clicked()

{

    SysOperationController            controller;

    SysOperationDataContract          dataContract;


    controller = new SysOperationController();


    controller.parmLoadFromSysLastValue(false);

    controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);

            //controller.getDataContractObject()//// for sys operation     //controller.parmReportContract().parmRdpContract()

    dataContract = controller.getDataContractObject('_contract'); // In service class in processOperation method we are declaring  DataContact as Variable. That variable buffer we have to declare here. Method Signature Ex: public void processOperation(SysOperationDataContract  _contract)


    dataContract.parmCustAccount(CustTable.AccountNum);// passing value


    controller.startOperation();

}

Getting caller Record in Sys Operation Click Here.

Keep Daxing!!

How to Get caller record in SysOperation in AX7/D365 fo

 

Hi guys, Today we see how to Get caller record in Sys operation Controller class in AX7/D365 fo.


Check the below class:


[SysOperationJournaledParametersAttribute(true)]

class DaxPriceDiscController extends SysOperationServiceController

{

    Common                      callerRecord;

    DAXPriceDiscDataContract    daxPriceDiscContract;

    PriceDiscAdmTable           priceDiscAdmTable;

    PriceDiscAdmTrans           priceDiscAdmTrans;


    public Common parmCallerRecord(Common _callerRecord = callerRecord)

    {

        callerRecord = _callerRecord;


        return callerRecord;

    }


    private void initFromCaller()

    {

        daxPriceDiscContract = this.getDataContractObject();


        switch (this.parmCallerRecord().TableId)

        {

            case tableNum(PriceDiscAdmTrans) :

                priceDiscAdmTrans = this.parmCallerRecord() as PriceDiscAdmTrans;


                daxPriceDiscContract.parmPriceDiscJournalNum(priceDiscAdmTrans.journalnum);

            break;

        }

    }


    public static DaxPriceDisccontroller newFromArgs(Args _args)

    {

        IdentifierName                  className;

        IdentifierName                  methodName;

        SysOperationExecutionMode       executionMode;

        DaxPriceDisccontroller          controller;


        [className, methodName, executionMode] = SysOperationServiceController::parseServiceInfo(_args);


        if (_args.record())

        {

            executionMode = SysOperationExecutionMode::Synchronous;

        }

        controller = new DaxPriceDisccontroller(className, methodName, executionMode);

        controller.parmArgs(_args);

        controller.parmCallerRecord(_args.record());


        return controller;

    }


    protected void refreshCallerRecord()

    {

        FormDataSource callerDataSource;

        if (this.parmCallerRecord() && this.parmCallerRecord().dataSource())

        {

            callerDataSource = this.parmCallerRecord().dataSource();

            callerDataSource.research(true);

        }

    }


    void new(IdentifierName _className = classStr(DaxPriceDiscService),

            IdentifierName _methodName = methodStr(DaxPriceDiscService, insertLines),

            SysOperationExecutionMode _executionMode = SysOperationExecutionMode::Synchronous)

    {

        super(_className, _methodName, _executionMode);


        this.parmClassName(classStr(DaxPriceDiscService));

        this.parmMethodName(methodStr(DaxPriceDiscService, insertLines));

    }


    Public static void Main(Args _args)

    {

        DaxPriceDiscController daxPriceDiscController= new DaxPriceDiscController();

        daxPriceDiscController = DaxPriceDiscController::newFromArgs(_args);

        daxPriceDiscController.initFromCaller();

        daxPriceDiscController.refreshCallerRecord();

        daxPriceDiscController.startOperation();

    }


    public DAXPriceDiscDataContract parmDaxPriceDiscContract(DAXPriceDiscDataContract _daxPriceDiscContract = daxPriceDiscContract)

    {

        daxPriceDiscContract = _daxPriceDiscContract;

        return daxPriceDiscContract;

    }

}


Keep Daxing!!

Wednesday, October 21, 2020

Select the batch tab in dialog by default using SysOperation in Ax 2012 X++


Hi guys, Today we see how to select the batch tab in dialog by default using SysOperation in Ax 2012 using X++.

In my Contract class I am not using any EDT. When I run Controller class the Dialog is Open with Empty general Tab. Like Below image.



For Avoiding this

Write Below method in Controller Class:

 protected void dialogPostRun()

{
    sysOperationDialog sysOperationDialog;
    DialogTabPage batchTab;
    FormRun formRun;

    super();

    sysOperationDialog = this.dialog() as SysOperationDialog;

    formRun = sysOperationDialog.formRun();

    batchTab = sysOperationDialog.batchDialogTabPage();

    formRun.selectControl(batchTab.control());
}

OutPut:




Keep Daxing!!

Tuesday, August 11, 2020

Initialize,Validate methods in contract class in ax 2012 using X++

 Hi guys,Today we see how to add Initialize,Validate methods in contract class in ax 2012 by X++.

In data contract class we have to use SysOperationAlwaysInitializeAttribute.

For Initialize we have to use SysOperationInitializable class.

For Validate we have to use SysOperationValidatable class.

The above 2 methods we have to add in data Contract Class By Implements Key Word.

Check Below code for better UnderStanding.


DataContract Class:

[DataContractAttribute,SysOperationAlwaysInitializeAttribute]

class SysOperationDemoDataContract implements SysOperationInitializable,SysOperationValidatable

{

    Name            name;

    BirthDate       birthDate;

}


Initialize method:

public void initialize()

{

    name='';

    birthDate= dateNull();

}


validate method:

public boolean validate()

{

    if (this.parmName('') )

    {

       return checkFailed('Enter Name Value');

    }

    return true;

}

Keep Daxing !!