Add notes as attachment via custom code in X++.
https://d365webgroups.blogspot.com/2024/08/add-notes-in-dynamics-365fo-using-x.html

Add notes as attachment via custom code in X++.


In my current project requirement a simple note is required to be added via code in D365 Finance and Operations masters. This is achieved via below code requirements.

Solution:

Let me tell in simple pattern to be followed which can be used in any format.

Step1. Create a Runnable class in Visual Studio after creating a new project and attaching models with it.


https://d365webgroups.blogspot.com/2024/08/add-notes-in-dynamics-365fo-using-x.html

Step2. Define the code.

class VendAccountDocument

{

? ? /// <summary>

? ? /// Runs the class with the specified arguments.

? ? /// </summary>

? ? /// <param name = "_args">The specified arguments.</param>

? ? public static void main(Args _args)

? ? {

? ? ? ? VendTable vendTable;

? ? ? ? DocuType docuType;

? ? ? ? DocuRef docuRef;

? ? ? ? vendTable = VendTable::find('104');

? ? ? ? docuType = DocuType::find('Note');

? ? ? ? if(!docuType||docuType.TypeGroup!=DocuTypeGroup::Note)

? ? ? ? {

? ? ? ? ? ? throw Error("Invalid document type");

? ? ? ? }

? ? ? ? docuRef.RefCompanyId = vendTable.DataAreaId;

? ? ? ? docuRef.RefTableId? ?= vendTable.TableId;

? ? ? ? docuRef.RefRecId? ? ?= vendTable.RecId;

? ? ? ? docuRef.TypeId? ? ? =? docuType.TypeId;

? ? ? ? docuRef.Name = 'Automatic note';

? ? ? ? docuRef.Notes = 'Automatic Notes';

? ? ? ? docuRef.insert();

? ? ? ? Info("Document note has been added successfully");

? ? }

}

Code Explanation:


https://d365webgroups.blogspot.com/2024/08/add-notes-in-dynamics-365fo-using-x.html

Result of this code:


https://d365webgroups.blogspot.com/2024/08/add-notes-in-dynamics-365fo-using-x.html

I wish this will help to take it further.

https://d365webgroups.blogspot.com/2024/08/add-notes-in-dynamics-365fo-using-x.html


要查看或添加评论,请登录

Divey Anand的更多文章

社区洞察

其他会员也浏览了