Sunday, December 27, 2020

Setting up alert on specific batch job in case of Error or canceled in Dynamics 365 finance and operations

Alerts are very important events for business and can be created to notify user based on the change. As everyone aware we can setup alert when create , update or delete actions performed on a record or specific field. but we can setup a alert for specific batch job in the system when it Ended , Failed or Cancelled. 

This can be done at the time of setting of the batch job.

Scenario:- 

We have a customer scenario where business user has to be notified when ever "Batch job history clean-up" job end with error or cancelled. 

Steps to configure:- 

1. Go to System Administrator > Periodic tasks >  Batch job history clean-up


























2. If you expand the run in the background section then we can see two options, Recurrence and Alerts. 







































3. Then click on Alerts and setup the events you want alerts to be triggered and click on ok 
4. In this case user fill get notified in the action center when ever the batch job "Batch job history clean-up" ended with error or canceled.
The same alert can be send as email but for that smtp server should be configured in email parameters.



Please note if you want to get alert then "Change based alerts" batch job should be running every min. 

Hope you find this useful and will come up with another interesting blog






Convert Electronic Reporting outbound documents from Microsoft Office formats to PDF in Dynamics 365 finance and operations

 As we aware new feature has been introduced in feature management in Dynamics 365 finance and operations with powerful features. but these features has been not enabled by default. 

Recently we have received a power full feature which coverts all electronic reporting outbound documents from Microsoft Office formats to PDF in Dynamics 365 finance and operations.

Go to System administration > Workspaces > Feature management and enable "Convert Electronic Reporting outbound documents from Microsoft Office formats to PDF" feature




Once we enable this then if you go back to Electronic reporting destination settings, we can see Convert to PDF checkbox enabled.

If you check this checkbox then document will be converted to PDF before we export.












Hope you find this useful and will come up with another interesting blog










Monday, December 21, 2020

Get default dimension name and description in Dynamics 365 finance and operations

I had requirement to get default dimension for Main account and when I look at internet I could see all of them  are so complex to get dimension name and description especially description. 

In fact we don't need all of them because in out of the box we have view which gives all this info by just one select query. if we have Default dimension and dimension. 


This view has method DefaultDimensionView.dimensionDiscription() which gives dimension description.

Please code for your reference, hope you find this useful!  

public static void main(Args _args)

    {

        #define.DimensionName("Department");

        DefaultDimensionView DefaultDimensionView;


        select firstonly DefaultDimensionView

             where DefaultDimensionView.Name == #DimensionName

                && DefaultDimensionView.DefaultDimension == 5637451520;//RecId of default dimension


        info(strFmt('Dimension Name: %1, Dimension description:%2', DefaultDimensionView.DisplayValue, DefaultDimensionView.dimensionDiscription()));

    }



Error settlement of Payments after removing AMC banking ISV solution.

 Our client uses AMC banking ISV solution for past 3 year and now they thought to quite and use existing features in out of the box with few customizations in case of out going payments as well as incoming payments. 

For outgoing payments we have "MultiCash (PL)" but its text file but client required in "ISO 20022 credit transfer", hence we have derived standard format and built new. 

For incoming payments we have used  "ISO20022 camt.054" and for advance bank reconciliation we have used "ISO20022 camt.053" with few minor changes in format and model mapping.

Everything was fine but finally we had an issue with settlement of customer or vendor payments. all the open transactions marked as "In use", hence we are not able to settle any transactions.

and we don't see any pending customer / vendor payment journals in the system. 

As everyone aware we need to remove reference in SpecTrans table hence I have built following script, may be you can find it useful if you face similar issues.

Once we ran this script then we are able to settle all the transactions which are struck in use.

public void clicked()

{

            SpecTrans       specTrans;

            CustTransOpen   custTransOpen;

            VendTransOpen   vendTransOpen;

            CustTrans       custTrans;

            VendTrans       vendTrans;

            container       conCustInvoice, conVendInvoice;

            int             totalCustInvoices, totalVendInvoices;


            if(Box::yesNo('@JP:DeleteAllSpecTransForPoland', DialogButton::Yes) == DialogButton::Yes)

            {

                changecompany('<Legal Entity>')

                {

                    ttsbegin;

                    while select specTrans join custTransOpen

                        where CustTransOpen.DataAreaId == specTrans.RefCompany

                        && CustTransOpen.RecId == specTrans.RefRecId

                        && CustTransOpen.TableId == specTrans.RefTableId

                        join custTrans

                        where custTrans.RecId == custTransOpen.RefRecId

                        && custTrans.AccountNum == custTrans.AccountNum

                    {

                        if (!conFind(conCustInvoice, custTrans.Invoice))

                        {

                            conCustInvoice += custTrans.Invoice;

                            

                        }

                        totalCustInvoices++;

                    }


                    info(con2Str(conCustInvoice));

                    info(strFmt('@JP:TotalSpecTransRecordsDeletedForCustomer', totalCustInvoices));


                    specTrans.skipDeleteActions(true);

                    specTrans.skipDatabaseLog(true);

                    specTrans.skipEvents(true);

                    specTrans.skipDataMethods(true);


                    delete_from specTrans exists join custTransOpen

                       where CustTransOpen.DataAreaId == specTrans.RefCompany

                        && CustTransOpen.RecId == specTrans.RefRecId

                        && CustTransOpen.TableId == specTrans.RefTableId;


                    while select specTrans join vendTransOpen

                        where vendTransOpen.DataAreaId == specTrans.RefCompany

                        && vendTransOpen.RecId == specTrans.RefRecId

                        && vendTransOpen.TableId == specTrans.RefTableId

                        join VendTrans

                        where VendTrans.RecId == vendTransOpen.RefRecId

                        && VendTrans.AccountNum == vendTransOpen.AccountNum

                    {

                        if (!conFind(conVendInvoice, vendTrans.Invoice))

                        {

                            conVendInvoice += vendTrans.Invoice;

                            

                        }

                        totalVendInvoices++;

                    }


                    specTrans.skipDeleteActions(true);

                    specTrans.skipDatabaseLog(true);

                    specTrans.skipEvents(true);

                    specTrans.skipDataMethods(true);


                    delete_from specTrans exists join vendTransOpen

                        where vendTransOpen.DataAreaId == specTrans.RefCompany

                        && vendTransOpen.RecId == specTrans.RefRecId

                        && vendTransOpen.TableId == specTrans.RefTableId;


                    info(con2Str(conVendInvoice));

                    info(strFmt('@JP:TotalSpecTransDeletedForVendor', totalVendInvoices));

                    info("@JP:OperationCompleted");

                    ttscommit;

                }

            }

            else

                info("@JP:OperationCancelled");

}