Posts

Custom service D365

Image
1)       Create contract class Example Code: [Microsoft.Dynamics.BusinessPlatform.SharedTypes. InternalUseOnlyAttribute , DataContractAttribute ( 'TANVehicleMasterDataContract' )] class TANVehicleMasterDataContract {     SalesAgreementId     salesAgreementId;     TANVehicleCategory   vehicleCategory;     TANVehicleFuelType   fuelType;     int                  vehicleID;     TANPlateNo           plateNo;     TANMake              make;     TANModel             model;     TAN_RFID_Gatex       RFIDGatex;     TANOdometer_Gatex    odometerGatex;     int total;       [DataMemberAttribute( "TotalCount" )]     public int parmTotalCount( int _total = total)     {         total = _total;         return total;     }       [DataMemberAttribute( "SalesAgreementId" )]     public SalesAgreementId parmsalesAgreementId( TANVehicleCategory _salesAgreementId = salesAgreementId)     {         salesAgreementId = _sale

COC to create custom method for forms

We can extend the logic of public and protected methods without having to use event handlers. COC, allows to use the method local and global variables. COC must be end with _Extension. Form level method : System search there are any extend methods , If Extend method is exist,run COC method first , next() method Invoke Standard form methods . Form Custom method:     [ ExtensionOf ( formstr ( CustTable ))] final class CustTableForm_Extension {     public amount getAmount( amount _amount)     {         //Here we can get buffers,Add logics and change parameter as per our business requirement.         Amount    retAmount = next getAmount(_amount);         //Here we can get buffers,Add logics and change return values as per our business requirement.          Return retAmount;     } } Get buffers :     FormRun formRun = this as   FormRun ; FormDataSource CustTable_DS =formRun.datasource(ForomDatasourceStr(CustTable,CustTable));

COC for Form level method

We can extend the logic of public and protected methods without having to use event handlers. COC, allows to use the method local and global variables. COC must be end with _Extension. Form level method : System search there are any extend methods , If Extend method is exist,run COC method first , next() method Invoke Standard form methods . Override Method: [ ExtensionOf ( formstr ( CustTable ))]     final class CustTableForm_Extension     {         public void init()         {             // here add the business logics             next init();             // here add the business logics         }     } Get buffers : FormRun formRun = this as   FormRun ;     FormDataSource CustTable_DS =formRun.datasource(ForomDatasourceStr(CustTable,CustTable));     CustTable custTable = CustTable_DS.Cursor();     FormControl custAccount = formRun.design().ControlName( FormControlStr ( FormName ,ControlName));        Example:

Find Price in sales order line (Trade Agreements)

class SMJ_SalesPriceTest {        public static void main( Args _args)     {         Amount retPrice;         PriceDiscParameters parameters = PriceDiscParameters ::construct();                 parameters.parmModuleType( ModuleInventPurchSales ::Sales);         parameters.parmItemId( "1000" );         //parameters.parmInventDim(InventDim::find());         parameters.parmUnitID( "ea" );         parameters.parmPriceDiscDate(systemDateGet());         parameters.parmQty( 50 );         parameters.parmAccountNum( "000001" );         parameters.parmCurrencyCode( CustTable ::find( "000001" ).Currency);         PriceDisc priceDisc = PriceDisc ::newFromPriceDiscParameters(parameters);         // From Trade agreement         if (priceDisc.findPrice( CustTable ::find( "000001" ).PriceGroup))         {             retPrice = priceDisc.price();         }         // From Item         else if (