Send Email with invoice as attachment using Electronic Reporting – Microsoft Dynamics 365 for Finance and Operation

Scenario:

Send Email with invoice as attachment thru electronic reporting

Solution:

Follow the below steps:

  1. Go to Electronic reporting workspace
  2. Click on the Electronic reporting destination

Screen Shot 2020-04-15 at 12.37.06 pm.png

3. Add new record in file destination grid settings type Émail’

Screen Shot 2020-04-15 at 12.38.33 pm.png

4.  Do the settings on the destination screen as below

Screen Shot 2020-04-15 at 12.41.05 pm.png

 

5. On To Field click Edit , click  and select print Management Email

Screen Shot 2020-04-15 at 12.42.43 pm

6. For above settings of Email Source account , click on link button before delete button ,it will open the formula designer , you need to select the field AccountNum (customer account number)

It will select the customer email defined on the customer Master contact details as primary

Screen Shot 2020-04-15 at 12.46.24 pm.png

 

7. click Save and close the formula designer form

8. click on the next two forms and now you can test the email by running the invoice print using print management

 

 

Leave your comments below  if you are facing any issue.

 

To send SSRS report in Email as attachment, please check below link

 

Send email thru code with Report as attachment – Dynamics 365 Finance and Operations

Copy attachments between different forms with data – Dynamics 365 for Finance and Operations

Scenario:

Sometime a requirement come that we need to copy the attachment from one form to another with the flow of data.

For example when purchase order creates from sales order then the attachment also need to be flow from sales order to purchase order

Solution:

First thing first -> Identify the relation between new and existing form(tables).

Then use the below code to achieve this.

I used the onInserted event ,you can use the same or whatever suitable for your scenario. Important thing is record should be created in new table then you can copy the attachment.

  

    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [DataEventHandler(tableStr(PurchTable), DataEventType::Inserted)]
    public static void PurchTable_onInserted(Common sender, DataEventArgs e)
    {
        PurchTable purchTable = sender;
        SalesTable salesTable = SalesTable::find(purchTable.InterCompanyOriginalSalesId);
        DocuRef docuRef = DocuRef::findTableIdRecId(salesTable.DataAreaId, salesTable.TableId, salesTable.RecId);

        if (docuRef)
        {
            docuRef.RefTableId = purchTable.TableId;
            docuRef.RefRecId = purchTable.RecId;
            docuRef.insert();
        }
    }

Leave your comments below if you have any query. I will try to help you to solve your problem

Data Entity Create Virtual Field – Microsoft Dynamics 365 for Finance and Operations

Scenario:
 
Requirement is to have a custom field showing Customer Number and Name.
 
Solution:
 
In that case instead of creating regular field on the Data entity and we will create a virtual field and fill the data at runtime when records are importing
 
Below are the steps needs to perform:
 
 
1. Create extension of the base entity (Example SalesOrderHeaderEntity) or your custom entity
 
2. Open the entity in designer and expand the fields
 
3. Right click and add new field -> StringUnmappedField
 
4. Set the Name property  of new field, in our case I put ‘CustomerNumberAndName’
 
5. Set the IsComputedField Property to No.
 
6. Leave the DataEntityViewMethod Empty
 
7.Use the virtual field to receive the information from outside(odata or excel) and parse the information
 
8. Use chain of command or pre-post event handler if its base entity or customise the method ‘mapEntityToDataSource’
 
‘example of mapEntityToDataSpurce’
 
9. 
public void mapEntityToDataSource(DataEntityRuntimeContext entityCtx, 
                                     DataEntityDataSourceRuntimeContext dataSourceCtx)
{
    next mapEntityToDataSource(entityCtx,dataSourceCtx);

    //Check if desired data source context is available
    switch (_dataSourceCtx.name())
    {
        case dataEntityDataSourceStr(SalesOrderHeaderV2Entity, SalesTable):
        {
            SalesTable salesTable      = _dataSourceCtx.getBuffer();
            this.CustomerNumberAndName = salesTable.InvoiceAccount + ' - ' salesTable.customerName();
        }
        break;
    }
}

10. You can get the value from odata also to use it for different purpose as per request