Post your Documents in D365F&O using X++ Plugins in Copilot

 1. PPAC > navigate to Environment > D365Academy-Dev> D365 Apps

we must have pre-request 

1. Copilot for Finance and Operations apps

2. Copilot in Microsoft Dynamics365 Finance 

2. Copilot in Microsoft Dynamics365 SCM

In feature management we must have enabled custom API Generator


1. Plug in class that is capable for target operations

a. Implements IcustomAPI

b. CustomAPI

c. AIPluinOerationAttibuite

d. CustomAPIRequestParameter

e. Microsaft Dynamics.Fno.Copilat.Plugins.InvakeFnoCustomAPI

/// <sunnary>

/// The plugin class that is capable of posting a slaes order packing slip

/// </sunnary>

{CustomAPI('Sales order packing slip plugin POC', 'Pest packing slip fer sales orders, frem Copilot')]

[AIPluginOperationAttribute]

[DataContract]


internal final class SubhaSOPostPackingSlipPluginV2 implements ICustomAPI

{

    private DataAreaId dataAreaId;

    private SalesId salesId;

    private ItemFreeTxt ret;


    [CustomAPIRequestParameter('Sales order Number', true), DataMember('salesId')]

    public SalesId parmSalesId(salesId _salesId = salesId)

    {

            salesId = _salesId;

            return salesId;

    }

    [CustomAPIRequestParameter('Legal ontity', true), DataMember('dataAreaId')]

    public DataAreaId parmDataAreaId(DataAreaId _dataAreaId = dataAreaId)

    {

            dataAreaId = _dataAreaId;

            return dataAreaID;

    }

    [CustomAPIResponseProperty('The result of the execution'),DataMember('ret')]

    public ItemFreeTxt parmret(ItemFreoTxt _ret = ret)

    {

            ret = _ret;

            return ret;

    }


/// <summary>Implementing the <m>run</m> method for the Plugin class

/// </sumnary>

/// <param name = "_args">The argument for the class implying any additonal inputs to passon</param>

    public void run(Args _args)

    {

        try

        {

            changecompany(dataAreaId)

            {

            SalesTable salesTable = SalesTable :: find(salesId);

          SalesFormLetter salesFormLetter = SalesFormLetter :: construct(DocumentStatus: :PackingSlip);

           salesFormLetter.update(salesTable);

           this.parmret("@AccountsReceivable:OperationCompleted");

            }

        }

        catch (Exception :: CLRError)

        {

            this.parmret(CLRInterop: :getLastException(). ToString());

        }

}


Once this is done - create a menu Item pointing to the class which is created now.

i have used the MI to Previlage

and created role .

Once done simply go to extension and deploy to my target environment, by selecting the model. 

Come to SA > Setup > Synchronize data verse custom APIs.


The the actually works start you need to create a custom API parameter, custom API parameter and custom API response parameter.


Come to make.powerapps.com > goto Solutions > create a solutions if not available.

Goto inside solution, click on new> More> custom API.(A form gets open) filli details 



Save and Close

Goto inside solution, click on new> More> custom API request parameter(A form gets open) filli details 

custom API request parameter kind of contract we need to define the data areaid and Sales order

Goto inside solution, click on new> More> custom API response property(A form gets open) filli details 


next goto copilotStudio.Microsoft.com, Goto Agent F&O.
Add tools>> going to let me allow to use the Custom API we created in last steep<<.
litter of options  chose Microsoft dataverse> from chose perform an unbound action in selected environment. 
connection string if first time if empty you can chose reward apatmete to connection.

add tool, 

Details 
    name Sale order packing slip
 Inputs 
        for environment details and action name selete the custom api we created now 
         Add inputs- add Data Area Id and SalesId order.
lets goto topic and 



Comments

Popular posts from this blog

Price disc agreement

Sample integration

Create ledger journals in D365FO using X++ + LedgerDimensionACType