Wednesday, April 20, 2022

how to display date without time in report using x++

Today we see how to display only date in report in D365FO. 


If we add date field in table it stores the data in date with time(12 am). If you see that field in form it will display only date but in report it will display both. To avoid this we need to use the expression. Just check below.


 




Use below expression in respective field box.

=Format(Fields!Culumn_Date.value,"dd/MM/yyyy")

-----------------------------or-------------------------------------------

=FormatDateTime(Fields!StartDate.Value, DateFormat.ShortDate)


OutPut:




Keep Daxing!!


Add default filter in Systemdefinedfiterpane in D365FO

 Today we see to add default filter in Systemdefinedfiterpane.




For this we need to use QueryFilter class. Write the below method in form init method. I am using vend group table.


[ExtensionOf(formStr(VendGroup))] public final class TestVendGroupForm_Extension { public void init() { next init(); // QueryFilter qFilter; QueryBuildDataSource qbd = VendGroup_ds.queryBuildDataSource(); // qFilter = VendGroup_ds.query().addQueryFilter(qbd, fieldStr(VendGroup, PaymTermId)) VendGroup_ds.query().addQueryFilter(qbd, fieldStr(VendGroup, PaymTermId)); //VendGroup_ds.query().addQueryFilter(qbd, fieldStr(VendGroup, Name));         

        // ------Or---------------         this.addFilterPaneRanges(); }     /// <summary> /// Adds ranges to filter pane. /// </summary> protected void addFilterPaneRanges() { QueryBuildDataSource inventSumQbds = InventSum_DS.query().dataSourceName(InventSum_DS.name()); SysQuery::findOrCreateRange(inventSumQbds, fieldNum(InventSum, ItemId)); QueryBuildDataSource inventTableQbds = InventTable_DS_DS.query().dataSourceName(InventTable_DS_DS.name()); SysQuery::findOrCreateRange(inventTableQbds, fieldNum(InventTable, NameAlias));

    } }


Keep Daxing!!

Tuesday, April 19, 2022

Postman Set up with D365FO

 Hi guys, Today we will see the steps to setup Postman with D365FO.


Step 1: Create a new application in Azure Platform to Register D365FO.

Step 2: After Registration we nee to copy the client Id and we need to add client id in D365FO.

URL/System administration/Setup/Azure Active Directory applications.

Step 3: Open the Postman and create a new collection. It has been renamed to 'Test API'.



Step 4: Click on Add request to get the token. Copy the 'TenantId' from the Azure portal.

https://login.microsoftonline.com/tenantId/oauth2/token


Step 5: Place the above link and select tab Body and click on 'x-www-form-urlencoded' or 'form-data' radio button.


Step 6: Provide below Key and Value details.

Key         Value

client_Id                   ClientID value 

grant_type client_credentials

client_secret Client secret

resource         D365FO Url

------------or--------------------

scope D365FO Url/.default

audience         D365FO Url


we can use resource or scope, audience.


Step 7: Click on Send button to get the access token.




To test this I am getting the customer groups from D365FO.

Step 8: Click on Add request to get the response.

Add this URL:D365FO url/data/CustomerGroups 

Step 9: Click on Authorization and select Bearer token and copy the access token. Click send button.



Keep Daxing!!



How to get table id in D365FO

 In D365FO is difficult to find the table id. We have 2 ways.


way 1: For this we need to write the below code.

            Info(strFmt('%1', tableNum(CustGroup)));


way 2: Written sql statement.

    For Table id:

    select * from SYSTABLEIDVIEW where name = 'custGroup'--id = '22163'



     For Table field id:

    select * from SYSTABLEFIELDIDVIEW where id = '4319'




Keep Daxing!!


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!!

Collection Classes in D365Fo

 Hi guys, Today we see all the collection classes with examples.

  • List
  • Set 
  • Map 
  • Array
  • Struct
List:

    Key words:
    myList.addEnd(string);//Adds value to end of the list myList.addStart(string);//Adds value to the beginning of the list myList.appendList(myList1);//Adds elements myList1 to the end of current list. myList.elements();//Returns the number of items in the list myList.getEnumerator();//This will returns an enumerator to get the values form list.   
    myList.toString();//This is convert list into string.

    
    Container = myList.pack();// Pack the list into a container
NewList = List::create(Container);// Create a new list from the packed list
List myList = con2List(Container);// Convert container

// Insert data into List
    List myList;
TempTable rmpLoc; myList = new List(Types::Record); for (tmpLoc = getFirstSelection(TmpTable_ds); tmpLoc ; tmpLoc = TmpTable_ds.getNext()) {     myList.addStart(iRBApprovalTmpLoc);
      // myList.addEnd(iRBApprovalTmpLoc);// add the data at end.     
}

myList.elements(); // return number of elements
  into list.

// Get data from List

    ListIterator:
    ListIterator literator = new ListIterator(myList);// my list
while (literator.more()) { tmpTable.data(literator.value()); }

    ListEnumerator: 

ListEnumerator enumerator = myList.getEnumerator();
while(enumerator.moveNext()) { iRBApprovalTmp.data(enumerator.current()); }
    
     Combine two lists into single list: 

    List myList        = new List(Types::String);
    List Newlist        = new List(Types::String);
    List combinedList   = new List(Types::String);
    
    combinedList = List::merge(myList, Newlist);
    print combinedList.toString();


Set:

    Key words:
        set    records = new set(Types::);
    records.add(value);// Add value to the set
    records.empty();// Check set is empty or not       
records.elements();//Returns the number of value in the set records.in(value);// it Checks the value is present in set or not. records.remove(value);// Remove the value from set. records.getEnumerator();// It getthe enumerator and will return the values i set.
    records.pack();//Convert into container. Set::difference(_set1, _set2);//Returns items that are in _set1 but are not in _set2 Set::intersection(_set1, _set2);// Duplicated values are returend. Set::union(_set1, _set2);//Combine the all the elements of _set1 and _set2

// Insert data into Set

    Set         records = new Set(Types::Int64);
    Notes       values;
    container   packed;
    ;
    
    records.add(tmpLoc.Recid);
    records.add(tmpLoc.Recid);
    
    // If you want conevert set to container 
    packed      = records.pack();
    values    = con2Str(packed, ',');// convert container to string

// Get data from Set

    SetIterator     recordsIterator;
    //recordsIterator = new SetIterator(
                            Set::create(packed));// If you using container we
                                                 //can follow like this
    recordsiterator = new setiterator(records);

    while (recordsiterator.more())
    {
        info(strfmt('%1',recordsiterator.value());

        recordsiterator.next();
    }

Map:

    Key Words;
       Map myMap = new Map(Types::Integer, Types::String);
myMap.remove(key);//Remove the value from map. myMap.elements();//Returns the number of key-value pairs in the map myMap.exists(key);//Returns true if _key is present in the map. myMap.insert(1,'Hi');// Insert record. myMap.lookup(Key);//Returns the corresponding value of _key.

// Insert data into Map

    Map myMap; myMap = new Map(Types::Integer, Types::String); myMap.insert(1, 'Test1'); myMap.insert(2, 'Test2'); myMap.insert(1, 'Test3');//Previous Test1 value overwritten with Test3.

// Get data from Map

    MapEnumerator   mapEnumerator;
    
    mapEnumerator = myMap.getEnumerator();
    while (mapEnumerator.moveNext()) 
    {
        info(strfmt("key %1 value %2",
            mapEnumerator.currentKey(),
            mapEnumerator.currentValue()));
    }

For struct and array check below link.




Keep Daxing!!

Get page number in report using x++

 Create a check box in the report design and right-click on that check box select the expression and place the below code.


=Globals!PageNumber & "-" & Globals!TotalPages

Or

=Labels!@SYS7426 & space(1) & Globals!PageNumber & space(1) & Labels!@SYS92595 & space(1) & Globals!TotalPages   


Keep Daxing!!