How to Import Records from Excel Using X++ Code in D365FO

  How to Import Records from Excel Using X++ Code in D365FO   Include the below namespace in X++ code it will requires to import Excel. Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange;   In addition to the basic reference, include (Directory and DirectoryUpgrade Packages) X++ Code: Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange; class ReadExcel {   public static void main(Args _args)    {     Int id;     Str Name;      System.IO.Stream stream;       ExcelSpreadsheetName sheet;              FileUploadBuild fileUpload,fileUploadBuild;       DialogGroup dialogUploadGroup;       FormBuildControl formBuildControl;   ...

Multi Select Lookup in SSRS Report in D365


Multi Select Lookup in SSRS Report in D365



Description:- 

we will create multi select lookup in SSRS report so that we can select multiple data from lookup.

Steps how to generate multi select lookup in SSRS report.

Create contract class for that and create method for parameters.

Contract Class: -
[DataContractAttribute, SysOperationContractProcessingAttribute(classstr(TestUIBuilder))]
class TestContract implements SysOperationValidatable
{
    List  ListItemId;
[DataMemberAttribute("Item Id"),AifCollectionTypeAttribute("Item Id"Types::String),
       SysOperationLabelAttribute(literalStr("Item Id"))]
       public List parmItemId(List _ListItemId = ListItemId)
{
              ListItemId = _ListItemId;
              return ListItemId;
}
}
//For validation parameters,
    public boolean validate()
    {
        boolean             isValid = true;
        List            ItemIdList = new List(Types::String);
        ItemIdList = this.parmItemId();
        if(!ItemIdList.elements())
        {
            isValid = checkFailed("ItemId should not be empty");
        }
        return isValid;
    }

Now Create AOT Query.
Now create UI Builder class.


UI Builder Class:-

class TestUIBuilder extends SysOperationAutomaticUIBuilder
{
    DialogField     dialogItemId
    TestContract TestContract;
}

private void ItemIdLookup(FormStringControl _control)
{
    Query       query;
    container   conItemId;
    query = new Query(queryStr(ItemListQuery));
    SysLookupMultiSelectGrid::lookup(query,_control,_control,conItemId);
}

public void build()
{
    int i;
    TestContract   contract;
    contract = this.dataContractObject() as TestContract;
    dialogItemId = this.addDialogField(methodStr(TestContract, parmItemId),contract);
}

public void postBuild()
{
    TestContract   contract;
    super();
    contract = this.dataContractObject() as TestContract;
    dialogItemId = this.bindInfo().getDialogField(contract,methodStr(TestContract, parmItemId));
    dialogItemId.registerOverrideMethod(methodStr(FormStringControl, lookup),
        methodStr(TestUIBuilder, ItemIdLookup),this);
    if (dialogItemId)
    {
        dialogItemId.lookupButton(2);
    }
}

public void postRun()
{
    //super();
}

Now Create Data Procedure class to run you login and get data from procedure.

Data Provider Class:-

[SRSReportParameterAttribute(classStr(TestContract))]
class TestDp extends SRSReportDataProviderBase
{
    TestContract contract;
    MyTable MyTable;
}

[SRSReportDataSetAttribute("MyTable")]
public MyTable get MyTable ()
{
    select * from MyTable;
    return MyTable;
}

[SysEntryPointAttribute]
public void processReport()
{
    List            list = new List(Types::String);
    Query                   queryItemId;
    QueryRun                queryRunItemId;
    InventItemGroupItem     InventItemGroupItem;
    QueryBuildDataSource    qbdsItemId;
    ListIterator            ItemIdListIterator;

    contract = this.parmDataContract() as TestContract;
    list = contract.parmItemId();
    if(list != null)
    {
        ItemIdListIterator = new ListIterator(list1);
        queryItemId = new Query(queryStr(ItemListQuery));
        qbdsItemId = queryItemId.dataSourceTable(tableNum(InventItemGroupItem));
        while(ItemIdListIterator.more())
        {
            qbdsItemId.addRange(
                fieldNum(InventItemGroupItem, ItemId)).value(ItemIdListIterator.value());
            ItemIdListIterator.next();
        }
        queryRunItemId = new QueryRun(queryItemId);
        while(queryRunItemId.next())
        {
            InventItemGroupItem = queryRunItemId.get(tableNum(InventItemGroupItem));
            Info(strfmt("ItemId - %1", InventItemGroupItem.ItemId));
        }
    }
}

Now in Visual Studio add the following
1.      Add Report
2.      Add Data Set
1.  Set the Properties for that Data Set.
3.      Set the Parameters you want to set blank value for ItemId Parameters
1.  Allow blank = true
2.  Nullable = true
4.      Add Precision Design
5.      Deployed SSRS Report and Run it.


Comments

Popular posts from this blog

D365 FO: REFRESH CALLER FORM DATA SOURCE FROM A CLASS X++

Passing Args from one Form to another Form in dynamics AX

CREATE AND POSTING PURCHASE ORDER THROUGH X++ DYNAMICS AX