Tuesday, March 31, 2020

Custom Form Dynamics 365

Right click on project -> Add -> New Item
select Form from the dialog box opened
put the name of the form and press Add
Now form will open automatically
Now drag the table that you want to add in the "Data Sources"
Now right click on "Design" -> Apply pattern -> select "Custom"
Now right click on "Design" -> New -> Grid
a new grid will be created
open the properties of the grid
put the name "Grid" and select the table in Data source
now drag the required fields into the grid from the datasource->tableName->Fields
now right click on project from solution explorer and rebuild your project
now to add the form on front end make a display menu item for the form
now create extension of required module in your project(AccountsReceivable in my case)
drag and drop the display menu item in the module

Monday, March 30, 2020

SSRS with ID filter Dynamics 365

Create a temporary table,in this case "CustReportTmp"
set table type property to "InMemory"
add the fields that you want to add in the report from the table you want to add
Now create a new RDP class,Best practice to suffix the rdp class name with DP
Now write the following code:

[SRSReportParameterAttribute(classStr(CustReportFilterContract))]
class CustReportFilterDP extends SRSReportDataProviderBase
{
    CustReportTmp   custReportTmp;
    TTC_CustID        ID;

    [SRSReportDataSetAttribute(tableStr('CustReportTmp'))]
    public custReportTmp getCustReportRDPDemoTmp()
    {
        select * from custReportTmp;
        return custReportTmp;
    }

    [SysEntryPointAttribute]
    public void processReport()
    {
        CustReportFilterContract    contract;
        TTC_Customer                customer;

        contract    = this.parmDataContract() as CustReportFilterContract;
        ID             = contract.parmID();

        while select * from customer where customer.ID  ==  ID
        {
            custReportTmp.clear();
            custReportTmp.ID              =   customer.ID;
            custReportTmp.Name        =   customer.Name;
            custReportTmp.Age           =   customer.Age;
            custReportTmp.Phone        =   customer.Phone;
            custReportTmp.EmailID     =   customer.EmailID;
            custReportTmp.Balance     =   customer.Balance;
            custReportTmp.insert();
        }
    }

}


now add a contract class

[DataContractAttribute]
class CustReportFilterContract
{
    TTC_CustID ID;

    [DataMemberAttribute("ID")]
    public TTC_CustID parmID(str _ID = ID)
    {
        ID  =   _ID;
        return ID;
    }

}

now right click on project -> add -> new item ->
than select "Report"
rename the report accordingly,in this case "ReportFilterRDP"
right click on dataset and add a dataset,name it accordingly
now go to properties of the dataset created
and put data source type to "Report Data Provider"
and select the query that we created (in this case we will select the class that we created)
now right click on design and create a new design
go to properties and give the name of the design and style template to "table style alternating rows"
now right click on design and click on "edit using designer"
now add a table from the ToolBox and and add the necessary fields that you want to add in the report
or you can make the report as per your requirements
now from the solution explorer right click on your report and click deploy report
now right click on project area and rebuild your project
add an output menu item for your report and place it in "Menu Extension" as per your requirement

Modified Field (Table Method) Dynamics 365

public class TTC_Order extends common
{
    public void modifiedField(FieldId _fieldId)
    {
        TTC_Customer        customer;
        TTC_WomenWear   womenwear;
        TTC_MenWear        menwear;
        TTC_KidWear         kidwear;
        super(_fieldId);
        if(_fieldId ==  fieldNum(TTC_Order,CustomerID))
        {
            select customer
                where customer.ID   ==  this.CustomerID;
            this.CustomerName   =   customer.Name;
            this.AccountType       =   customer.CustomerType;
        }

        if(_fieldId ==  fieldNum(TTC_Order,ItemId))
        {
            if(this.Category    ==  TTC_Category::Kid)
            {
                select kidwear
                    where kidwear.ID    ==  this.ItemId;
                this.ItemType   =   kidwear.Type;
            }
            if(this.Category    ==  TTC_Category::Men)
            {
                select menwear
                    where menwear.ID    ==  this.ItemId;
                this.ItemType   =   menwear.Type;
            }
            if(this.Category    ==  TTC_Category::Women)
            {
                select womenwear
                    where womenwear.ID  ==  this.ItemId;
                this.ItemType   =   womenwear.Type;
            }
        }

        if(_fieldId ==  fieldNum(TTC_Order,Quantity))
        {
            if(this.Category    ==  TTC_Category::Kid)
            {
                select kidwear
                    where kidwear.ID    ==  this.ItemID;
                this.Amount =   this.Quantity * kidwear.Price;
            }
            if(this.Category    ==  TTC_Category::Men)
            {
                select menwear
                    where menwear.ID    ==  this.ItemID;
                this.Amount =   this.Quantity * menwear.Price;
            }
            if(this.Category    ==  TTC_Category::Women)
            {
                select womenwear
                    where womenwear.ID  ==  this.ItemID;
                this.Amount =   this.Quantity * womenwear.Price;
            }
        }
    }

}

Starting a project Dynamics 365

Make your project
now click on "Dynamics 365" in action pane
select "Model Management"
select "Create Model"
a popup menu will appear
Name the model "TTC_CustomModel"
Model publisher "Tectree"
Model Description "This model contains all custom customizations"
click next
select "Create new package"
click next
select
application common,application foundation,application platform,application suite,calendar,contact person,currency,dimensions,directory,electronic reporting,
fiscal books,general ledger,ledger,personnel,policy,retail,subledger,tax,unit of measure
click next

go to the properties of the project
select the right model
syncronise database on build  -  false (so that building project won't take much time)


go to dynamics 365 -> options
now select project
now tick "organise projects by element type"
and click ok