Wednesday 30 June 2021

Add Grid Control to dialog form in Sys Operation Framework in D365 F&SCM

 Hi All,


Recently I have a requirement for adding the grid control to the dialog form for one of the batch processing operation using sys operation framework.

So let's explore how to do it:


  • It will be really difficult to add the grid control at run time in dialog form using code, so better to create a new form with dialog pattern as Dialog - FastTabs


  • Now in your controller class, override "templateForm" method and give our custom dialog form name as shown below:
  • This will override the standard dialog form and use our custom form.

  • Now since we have implemented a new custom form instead of standard dialog form, we will not get the option "Records to include" for filtering data as we do in standard dialog form, so to resolve this issue, create a new button in your form (Label it as "Records to include") and use the below code on click of this button to get the "Records to include" button as below:

  • In the above image "isQueryRunData" and "queryRun" are global variables, which will help us to decide when to update the standard query in executeQuery() of form data source with our new filtered query after we select some filters in our query using Records To Include button so that our data in the grid gets modified based on the filter selection as shown below:



  • Now we want to pass our modified query back to our contract class SetQuery() so that it can update the original query object of controller class with our filtered query, to get that write code as below on the click of "close ok" button of our form:


  • Now finally in the "processOperation()" of service class fetch the query using queryRun() and loop the data:
    


  • Finally this is how our form will look like:



  • Click on Records To Include Button to view the filter form:




  • Thanks for reading this, let me know if you need any clarification.

Tuesday 1 June 2021

How to check if a customer contains a specific Location Role and find the Logistics Location Id for that specific location role

 Below method will check if a customer contains a specific Location Role or not and find the Logistics Location Id for that specific location role:


This is where you can check the location role for a customer:






public LogisticsLocationId getLogisticsLocationId(CustAccount _custAccount)

{

        DirPartyAddressLocationRoleNames    locationRoleNames;

        DirPartyPostalAddressView                   addressView;

        LogisticsLocation                                   logisticsLocation;

        CustTable                                               custTable = CustTable::find(_custAccount);


        select firstonly PartyLocation from addressView

            where addressView.Party == custTable.Party;


        locationRoleNames = addressView.locationRoles();


        str billTo = 'Bill to'; // Here you should write the name of your location role which needs to be find out.

        if (strScan(locationRoleNames, billTo, 1, strLen(locationRoleNames)))

        {

            DirPartyLocation dirPartyLocation;

            select firstonly LocationId from logisticsLocation

                join Location from dirPartyLocation

                    where logisticsLocation.RecId ==  dirPartyLocation.Location

                        && dirPartyLocation.Party == custTable.Party;

        }


        return logisticsLocation.LocationId;

    }


Insert/Update or remove the default dimension value in D365 FSCM via x++

Use below method to insert/update the dimension values, just pass the parameter values to the method and it will return the updated value: p...