Have you ever thought of using your copilot to manage transferring call from one topic to another? A typical example would be to create a sales order in D365F&O from one topic, and then you want to keep adding sales lines to the generated sales order. Or you want to generate a customer record, and keep adding addresses and contacts to it.
Yes, transferring calls from one topic to another is easy and could help you transfer just not the controls but also variables from one to the next.
This article shows you how to implement this, step-by-step.
You ask the copilot something like this:

When the copilot comes back to you like this:

And then you give it instructions like this:

To which the Copilot comes back to you like this:

If you select Ok, it will ask to provide details to create sales line:

And to which you reply:

And then the Copilot comes back, saying that the line got added successfully:

You can keep adding more lines to it, or choose to exit by clicking No, which would make the Copilot sign off from the conversation:

And you got it correct. The first header was created from one Topic, and then the lines were getting created to the header from another topic, with the sales header getting transferred as a Parameter with each call.
Please read along to see how this could be done 😊

I am defining a prompt like this:

Where I am passing a Variable ‘salesorderprompt’ that looks like this:

This would translate the values of Customer code, site, warehouse, item Id, quantity, etc. as a JSON. Click on test prompt, it will show you like this:

Likewise, let us also create another prompt like this, for sales line:

Where the variable called saleslinedetails looks like this:

Click on the test prompt, it would show a JSON like this:


Here you are defining few phrases like ‘Sales order’, ‘sales order creation’, etc., meaning when the user gives a prompt like ‘Sales order creation’, it would understand to create Sales Orders.
I am saving the entire response as a variable called ‘salesOrderDetails’:

Which is a string type variable, and a local variable:


As a next step, we are calling the Prompt we created from Step-1, to create the JSON for Sales header creation:

Let us parse the JSON to get the variables provided by the user:

The JSON schema is what we have got in Step-1: this will essentially help us get all the values of the variables for Customer account number, Item Id, Qty, sales price, etc. With these we will create the sales order, in the subsequent steps.
We are calling a HTTP post to call the AAD token:

And in the next step we will call the Sales order OData entity, to create the sales order header (note that we are passing on the bearer token as authorization):

The body of the sales order looks like this:
{
"dataAreaId": "@{body('Parse_JSON_sales_order_details')?['legalEntity']}",
"FiscalDocumentOperationTypeId": "",
"OrderTakerPersonnelNumber": "",
"RequestedReceiptDate": "@{body('Parse_JSON_sales_order_details')?['date']}",
"EInvoiceDimensionAccountCode": "",
"IsOwnEntryCertificateIssued": "No",
"CampaignId": "",
"Email": "",
"DefaultShippingSiteId": "@{body('Parse_JSON_sales_order_details')?['site']}",
"TransportationBrokerId": "",
"TransportationModeId": "",
"DeliveryAddressDescription": "",
"CFPSCode": "",
"IsSalesProcessingStopped": "No",
"TMACustomerGroupId": "",
"NumberSequenceGroupId": "",
"SalesOrderOriginCode": "",
"CustomerPaymentFinancialInterestCode": "",
"TransportationTemplateId": "",
"IsOneTimeCustomer": "No",
"SalesOrderPoolId": "",
"DeliveryAddressCountryRegionId": "",
"DeliveryAddressLatitude": 0,
"TotalDiscountCustomerGroupCode": "",
"DeliveryAddressCity": "",
"SalesRebateCustomerGroupId": "",
"ThirdPartySalesDigitalPlatformCNPJ": "",
"SalesOrderPromisingMethod": "None",
"ShippingCarrierId": "",
"TotalDiscountPercentage": 0,
"DeliveryAddressDistrictName": "",
"DeliveryAddressCountyId": "",
"ConfirmedReceiptDate": "@{body('Parse_JSON_sales_order_details')?['date']}",
"DeliveryAddressZipCode": "",
"FiscalOperationPresenceType": "DoesNotApply",
"QuotationNumber": "",
"IsConsolidatedInvoiceTarget": "No",
"LanguageId": "en-us",
"DeliveryAddressDunsNumber": "",
"MultilineDiscountCustomerGroupCode": "",
"CustomerPaymentMethodSpecificationName": "",
"ServiceFiscalInformationCode": "",
"CommissionCustomerGroupId": "",
"DeliveryAddressName": "Test customer 2",
"PaymentTermsBaseDate": "1900-01-01T12:00:00Z",
"DeliveryAddressStreetNumber": "",
"CreditNoteReasonCode": "",
"ChargeCustomerGroupId": "",
"TaxExemptNumber": "",
"IsDeliveryAddressPrivate": "No",
"CustomersOrderReference": "",
"ExportReason": "",
"OrderResponsiblePersonnelNumber": "",
"DeliveryAddressCountryRegionISOCode": "",
"CashDiscountCode": "",
"PaymentScheduleName": "",
"IntrastatTransactionCode": "",
"URL": "",
"CurrencyCode": "@{body('Parse_JSON_sales_order_details')?['currency']}",
"InvoiceType": "Invoice",
"ArePricesIncludingSalesTax": "No",
"InvoiceCustomerAccountNumber": "@{body('Parse_JSON_sales_order_details')?['customer']}",
"DeliveryAddressLocationId": "",
"CustomerTransactionSettlementType": "None",
"CommissionSalesRepresentativeGroupId": "",
"WillAutomaticInventoryReservationConsiderBatchAttributes": "No",
"IntrastatStatisticsProcedureCode": "",
"IsEInvoiceDimensionAccountCodeSpecifiedPerLine": "No",
"DeliveryAddressStreet": "",
"DeliveryModeCode": "",
"IsExportSale": "No",
"ConfirmedShippingDate": "@{body('Parse_JSON_sales_order_details')?['date']}",
"FixedDueDate": "1900-01-01T12:00:00Z",
"SalesTaxGroupCode": "",
"IsDeliveryAddressOrderSpecific": "No",
"CustomerRequisitionNumber": "",
"IsFinalUser": "No",
"ShippingCarrierServiceGroupId": "",
"ContactPersonId": "",
"EUSalesListCode": "",
"ThirdPartySalesDigitalPlatform": "No",
"PaymentTermsName": "",
"CustomerPostingProfileId": "GEN",
"DeliveryTermsCode": "",
"ShippingCarrierServiceId": "",
"DefaultLedgerDimensionDisplayValue": "",
"DeliveryAddressTimeZone": null,
"SalesOrderName": "Test customer 2",
"DefaultShippingWarehouseId": "@{body('Parse_JSON_sales_order_details')?['warehouse']}",
"IsEntryCertificateRequired": "No",
"DeliveryAddressStateId": "",
"DeliveryBuildingCompliment": "",
"IntrastatTransportModeCode": "",
"InvoicePaymentAttachmentType": "None",
"DeliveryAddressPostBox": "",
"InvoiceAddressTimeZone": null,
"DirectDebitMandateId": "",
"LineDiscountCustomerGroupCode": "",
"IntrastatPortId": "",
"OrderingCustomerAccountNumber": "@{body('Parse_JSON_sales_order_details')?['customer']}",
"CustomerPaymentFineCode": "",
"PriceCustomerGroupCode": "",
"DeliveryReasonCode": "",
"IsServiceDeliveryAddressBased": "No",
"InventoryReservationMethod": "Automatic",
"RequestedShippingDate": "@{body('Parse_JSON_sales_order_details')?['date']}",
"TransportationRoutePlanId": "",
"CustomerPaymentMethodName": "",
"SalesUnitId": "",
"FixedExchangeRate": 0
}
Evidently we are hardcoding some values, and some we are passing as variables obtained from the above step (parse JSON step).
This will create the sales order with the payload as follows:
{
"@odata.context": "<base_url>/data/$metadata#SalesOrderHeadersV3/$entity",
"@odata.etag": "W/\"JzYxNTkwOTgwNiw2ODcxOTUyMjQwMTsxLDY4NzE5NDc4MjY0OzAsMDswLDA7MSw2ODcxOTQ3Njc3MzswLDA7MCwwOzAsMCc=\"",
"dataAreaId": "usmf",
"SalesOrderNumber": "000946",
"CustomerRequisitionNumber": "",
"SalesOrderProcessingStatus": "Active",
"OrderTotalAmount": 0,
"IntrastatPortId": "",
"ContactPersonId": "",
"CustomersOrderReference": "",
"SkipCreateAutoCharges": "Yes",
"TotalDiscountPercentage": 0,
"CustomerPaymentFineCode": "",
"IsSalesProcessingStopped": "Yes",
"InventoryReservationMethod": "Automatic",
"IntrastatTransportModeCode": "",
"InvoiceCustomerAccountNumber": "Cu00000111",
"URL": "",
"InvoiceAddressCity": "",
"BankSpecificSymbol": "",
"BaseDocumentNumber": "",
"IsFinalUser": "No",
"CFPSCode": "",
"InvoiceAddressStreet": "",
"InvoiceAddressCountyId": "",
"DeliveryAddressCountryRegionId": "",
"IsServiceDeliveryAddressBased": "No",
"InvoiceAddressDistrictName": "",
"InvoiceAddressTimeZone": null,
"FiscalOperationPresenceType": "DoesNotApply",
"MultilineDiscountCustomerGroupCode": "",
"IsOwnEntryCertificateIssued": "No",
"DeliveryAddressCountyId": "",
"DefaultShippingWarehouseId": "12",
"DeliveryAddressLocationId": "",
"CustomerPaymentMethodName": "",
"SalesUnitId": "",
"DefaultLedgerDimensionDisplayValue": "",
"DeliveryAddressCountryRegionISOCode": "",
"AreTotalsCalculated": "No",
"TaxExemptNumber": "",
"DeliveryAddressDescription": "",
"DeliveryAddressLongitude": 0,
"DefaultShippingSiteId": "1",
"CashDiscountCode": "",
"DeliveryReasonCode": "",
"TotalDiscountCustomerGroupCode": "",
"CampaignId": "",
"OrderTotalDiscountAmount": 0,
"PaymentTermsName": "",
"ShippingCarrierServiceGroupId": "",
"CIPEcode": "",
"RequestedReceiptDate": "2025-02-15T12:00:00Z",
"ConfirmedReceiptDate": "2025-02-15T12:00:00Z",
"BaseDocumentDate": "1900-01-01T12:00:00Z",
"EInvoiceDimensionAccountCode": "",
"OrderingCustomerAccountNumber": "Cu00000111",
"OrderTotalChargesAmount": 0,
"SalesRebateCustomerGroupId": "",
"TransportationBrokerId": "",
"DirectDebitMandateId": "",
"CreditNoteReasonCode": "",
"IntrastatStatisticsProcedureCode": "",
"TMACustomerGroupId": "",
"ArePricesIncludingSalesTax": "No",
"IsExportSale": "No",
"InvoicePaymentAttachmentType": "None",
"ReportingCurrencyFixedExchangeRate": 0,
"IsDeliveryAddressPrivate": "No",
"DeliveryAddressCity": "",
"DeliveryAddressStreet": "",
"NumberSequenceGroupId": "",
"OrderTotalTaxAmount": 0,
"DeliveryTermsCode": "",
"ChargeCustomerGroupId": "",
"WillAutomaticInventoryReservationConsiderBatchAttributes": "No",
"SalesTaxGroupCode": "",
"IsInvoiceAddressPrivate": "No",
"ThirdPartySalesDigitalPlatformCNPJ": "",
"OrderHeaderTaxAmount": 0,
"FiscalDocumentOperationTypeId": "",
"OrderCreationDateTime": "2025-02-24T02:59:07Z",
"SalesOrderOriginCode": "",
"ServiceFiscalInformationCode": "",
"DeliveryAddressStateId": "",
"FulfillmentPolicyName": "",
"CommissionSalesRepresentativeGroupId": "",
"CustomerPostingProfileId": "GEN",
"CustomerTransactionSettlementType": "None",
"BaseDocumentItemNumber": "",
"TransportationDocumentLineId": "00000000-0000-0000-0000-000000000000",
"DeliveryAddressStreetInKana": "",
"CustomerPaymentFinancialInterestCode": "",
"PaymentScheduleName": "",
"InvoiceAddressStreetNumber": "",
"SalesOrderStatus": "None",
"PaymentTermsBaseDate": "1900-01-01T12:00:00Z",
"ShippingCarrierId": "",
"InvoiceAddressPostBox": "",
"ConfirmedShippingDate": "2025-02-15T12:00:00Z",
"TenderCode": "",
"DeliveryAddressDunsNumber": "",
"IsEntryCertificateRequired": "No",
"ThirdPartySalesDigitalPlatform": "No",
"DeliveryAddressDistrictName": "",
"SalesOrderPromisingMethod": "None",
"DeliveryModeCode": "",
"BaseDocumentLineNumber": 0,
"TransportationModeId": "",
"SalesOrderName": "Test customer 2",
"DeliveryAddressStreetNumber": "",
"InvoiceAddressLongitude": 0,
"InvoiceAddressLatitude": 0,
"BaseDocumentType": "None",
"SalesOrderPoolId": "",
"FormattedInvoiceAddress": "",
"CustomerPaymentMethodSpecificationName": "",
"CurrencyCode": "USD",
"FormattedDelveryAddress": "",
"BankConstantSymbol": "",
"PriceCustomerGroupCode": "",
"DeliveryAddressTimeZone": null,
"FullRunCTPStatus": "Ready",
"Email": "",
"ExcludeFromMasterPlanning": "No",
"InvoiceAddressCityInKana": "",
"InvoiceAddressCountryRegionISOCode": "",
"TransportationTemplateId": "",
"IsConsolidatedInvoiceTarget": "No",
"OrderOrAgreementCode": "",
"TransportationRoutePlanId": "",
"FixedDueDate": "1900-01-01T12:00:00Z",
"DeliveryAddressName": "Test customer 2",
"ExportReason": "",
"FixedExchangeRate": 0,
"IntrastatTransactionCode": "",
"InvoiceAddressStreetInKana": "",
"InvoiceBuildingCompliment": "",
"RetailChannelTable": 0,
"InvoiceAddressZipCode": "",
"TotalDiscountAmount": 0,
"ShippingCarrierServiceId": "",
"IsOneTimeCustomer": "No",
"DeliveryAddressZipCode": "",
"OrderTakerPersonnelNumber": "",
"DeliveryAddressCityInKana": "",
"DeliveryAddressPostBox": "",
"IsDeliveryAddressOrderSpecific": "No",
"InvoiceAddressStateId": "",
"RequestedShippingDate": "2025-02-15T12:00:00Z",
"DeliveryAddressLatitude": 0,
"DeliveryBuildingCompliment": "",
"InvoiceAddressCountryRegionId": "",
"IsEInvoiceDimensionAccountCodeSpecifiedPerLine": "No",
"InvoiceType": "Invoice",
"EUSalesListCode": "IncludeNot",
"ProjectId": "",
"OverrideSalesTax": "No",
"QuotationNumber": "",
"OrderResponsiblePersonnelNumber": "",
"CommissionCustomerGroupId": "",
"LanguageId": "en-us",
"LineDiscountCustomerGroupCode": "",
"ShippingCarrierCustomerAccountNumber": "",
"SubBillCreatedFromSubscriptionBilling": "No",
"RevRecReallocationId": "",
"RevRecFollowOriginalPricingMethod": "No",
"RevRecMultipleSOReallocation": "No",
"RevRecContractEndDate": "1900-01-01T12:00:00Z",
"RevRecLatestReverseJournal": 0,
"RevRecContractStartDate": "1900-01-01T12:00:00Z",
"SkipGlobalUnifiedPricingCalculation": "No"
}
That’s it: our sales order has got created in this step. We would need the sales Id, and hence we are creating a variable called SalesId, which we are getting from the JSON response above:

To which we are again calling the Sales Line entity:

And in the body we are passing on the all the variables from the above step, some we are hardcoding. As this is the first line, hence we are not assigning the Line number explicitly. Sales Id, which we are getting from the above step, we are assigning it here:

And then we are returning thee sales Id generated to the Copilot as a last step of the flow:


On getting the response from Flow, we are displaying as a response to the user.
Next we are asking the user the question, if he wants to add more lines:

Where Consent is a custom entity which I have created previously for obtaining the user input. If the User chooses OK, it will create transfer the call to another Topic. Else it will end the conversation, there itself:

Where evidently ‘Add more sales lines’ is my new topic to transfer, and I am passing my newly created SalesId and SalesOrderDetails variables to this topic.
This you can do by configuring the topic to accept variables as:

And then marking the variable to accept values from other topic:

And here also I am calling another flow, which is inserting more lines to sales line (just like we did in the previous step).
Except that, we need to take care of the sales line number here. The sales line number must be increased by one, before insert. For that we need to get the max of Line number till the last sales line inserted:
<Base_url>/data/SalesOrderLines?cross-company=true&$top=1&$select=LineNumber&$filter=SalesOrderNumber eq '' and dataAreaId eq ''
This is something like:
Select maxof(LineNum) from salesLine where salesline.salesId == <some_number>
And then while inserting in the sales line entity, we are increasing it by one:

And back in the Copilot I am recursively calling the sales line topic like this:

Which the copilot assesses by calling it back again and again:

Thus the user could keep on adding more and more lines to the sales order, as long as he is not choosing No – when the cycle breaks, and the Copilot responds back:

In the above step, I have added message variations which will make the Copilot respond with new responses, as the user chooses to conclude the conversation.
Let me conclude the discussion here. Please try the same at your end and let me know how it goes.
Signing off for now, much love and Namaste 😊 😊
Yes, transferring calls from one topic to another is easy and could help you transfer just not the controls but also variables from one to the next.
This article shows you how to implement this, step-by-step.
Setting the background
Imaging creating a sales order could be as easy like this –You ask the copilot something like this:
When the copilot comes back to you like this:
And then you give it instructions like this:
To which the Copilot comes back to you like this:
If you select Ok, it will ask to provide details to create sales line:
And to which you reply:
And then the Copilot comes back, saying that the line got added successfully:
You can keep adding more lines to it, or choose to exit by clicking No, which would make the Copilot sign off from the conversation:
And you got it correct. The first header was created from one Topic, and then the lines were getting created to the header from another topic, with the sales header getting transferred as a Parameter with each call.
Please read along to see how this could be done 😊
Step 1
Create a PowerApps AI prompt, by visiting https://make.powerapps.com >> choosing the correct environment:I am defining a prompt like this:
Where I am passing a Variable ‘salesorderprompt’ that looks like this:
This would translate the values of Customer code, site, warehouse, item Id, quantity, etc. as a JSON. Click on test prompt, it will show you like this:
Likewise, let us also create another prompt like this, for sales line:
Where the variable called saleslinedetails looks like this:
Click on the test prompt, it would show a JSON like this:
Step 2
Let us go to Copilot Studio and create a topic like this, under Copilot for Finance and Operations apps:Here you are defining few phrases like ‘Sales order’, ‘sales order creation’, etc., meaning when the user gives a prompt like ‘Sales order creation’, it would understand to create Sales Orders.
I am saving the entire response as a variable called ‘salesOrderDetails’:
Which is a string type variable, and a local variable:
Step 3
In the next step, I am calling a Flow which would accept the user input and process it further:As a next step, we are calling the Prompt we created from Step-1, to create the JSON for Sales header creation:
Let us parse the JSON to get the variables provided by the user:
The JSON schema is what we have got in Step-1: this will essentially help us get all the values of the variables for Customer account number, Item Id, Qty, sales price, etc. With these we will create the sales order, in the subsequent steps.
We are calling a HTTP post to call the AAD token:
And in the next step we will call the Sales order OData entity, to create the sales order header (note that we are passing on the bearer token as authorization):
The body of the sales order looks like this:
{
"dataAreaId": "@{body('Parse_JSON_sales_order_details')?['legalEntity']}",
"FiscalDocumentOperationTypeId": "",
"OrderTakerPersonnelNumber": "",
"RequestedReceiptDate": "@{body('Parse_JSON_sales_order_details')?['date']}",
"EInvoiceDimensionAccountCode": "",
"IsOwnEntryCertificateIssued": "No",
"CampaignId": "",
"Email": "",
"DefaultShippingSiteId": "@{body('Parse_JSON_sales_order_details')?['site']}",
"TransportationBrokerId": "",
"TransportationModeId": "",
"DeliveryAddressDescription": "",
"CFPSCode": "",
"IsSalesProcessingStopped": "No",
"TMACustomerGroupId": "",
"NumberSequenceGroupId": "",
"SalesOrderOriginCode": "",
"CustomerPaymentFinancialInterestCode": "",
"TransportationTemplateId": "",
"IsOneTimeCustomer": "No",
"SalesOrderPoolId": "",
"DeliveryAddressCountryRegionId": "",
"DeliveryAddressLatitude": 0,
"TotalDiscountCustomerGroupCode": "",
"DeliveryAddressCity": "",
"SalesRebateCustomerGroupId": "",
"ThirdPartySalesDigitalPlatformCNPJ": "",
"SalesOrderPromisingMethod": "None",
"ShippingCarrierId": "",
"TotalDiscountPercentage": 0,
"DeliveryAddressDistrictName": "",
"DeliveryAddressCountyId": "",
"ConfirmedReceiptDate": "@{body('Parse_JSON_sales_order_details')?['date']}",
"DeliveryAddressZipCode": "",
"FiscalOperationPresenceType": "DoesNotApply",
"QuotationNumber": "",
"IsConsolidatedInvoiceTarget": "No",
"LanguageId": "en-us",
"DeliveryAddressDunsNumber": "",
"MultilineDiscountCustomerGroupCode": "",
"CustomerPaymentMethodSpecificationName": "",
"ServiceFiscalInformationCode": "",
"CommissionCustomerGroupId": "",
"DeliveryAddressName": "Test customer 2",
"PaymentTermsBaseDate": "1900-01-01T12:00:00Z",
"DeliveryAddressStreetNumber": "",
"CreditNoteReasonCode": "",
"ChargeCustomerGroupId": "",
"TaxExemptNumber": "",
"IsDeliveryAddressPrivate": "No",
"CustomersOrderReference": "",
"ExportReason": "",
"OrderResponsiblePersonnelNumber": "",
"DeliveryAddressCountryRegionISOCode": "",
"CashDiscountCode": "",
"PaymentScheduleName": "",
"IntrastatTransactionCode": "",
"URL": "",
"CurrencyCode": "@{body('Parse_JSON_sales_order_details')?['currency']}",
"InvoiceType": "Invoice",
"ArePricesIncludingSalesTax": "No",
"InvoiceCustomerAccountNumber": "@{body('Parse_JSON_sales_order_details')?['customer']}",
"DeliveryAddressLocationId": "",
"CustomerTransactionSettlementType": "None",
"CommissionSalesRepresentativeGroupId": "",
"WillAutomaticInventoryReservationConsiderBatchAttributes": "No",
"IntrastatStatisticsProcedureCode": "",
"IsEInvoiceDimensionAccountCodeSpecifiedPerLine": "No",
"DeliveryAddressStreet": "",
"DeliveryModeCode": "",
"IsExportSale": "No",
"ConfirmedShippingDate": "@{body('Parse_JSON_sales_order_details')?['date']}",
"FixedDueDate": "1900-01-01T12:00:00Z",
"SalesTaxGroupCode": "",
"IsDeliveryAddressOrderSpecific": "No",
"CustomerRequisitionNumber": "",
"IsFinalUser": "No",
"ShippingCarrierServiceGroupId": "",
"ContactPersonId": "",
"EUSalesListCode": "",
"ThirdPartySalesDigitalPlatform": "No",
"PaymentTermsName": "",
"CustomerPostingProfileId": "GEN",
"DeliveryTermsCode": "",
"ShippingCarrierServiceId": "",
"DefaultLedgerDimensionDisplayValue": "",
"DeliveryAddressTimeZone": null,
"SalesOrderName": "Test customer 2",
"DefaultShippingWarehouseId": "@{body('Parse_JSON_sales_order_details')?['warehouse']}",
"IsEntryCertificateRequired": "No",
"DeliveryAddressStateId": "",
"DeliveryBuildingCompliment": "",
"IntrastatTransportModeCode": "",
"InvoicePaymentAttachmentType": "None",
"DeliveryAddressPostBox": "",
"InvoiceAddressTimeZone": null,
"DirectDebitMandateId": "",
"LineDiscountCustomerGroupCode": "",
"IntrastatPortId": "",
"OrderingCustomerAccountNumber": "@{body('Parse_JSON_sales_order_details')?['customer']}",
"CustomerPaymentFineCode": "",
"PriceCustomerGroupCode": "",
"DeliveryReasonCode": "",
"IsServiceDeliveryAddressBased": "No",
"InventoryReservationMethod": "Automatic",
"RequestedShippingDate": "@{body('Parse_JSON_sales_order_details')?['date']}",
"TransportationRoutePlanId": "",
"CustomerPaymentMethodName": "",
"SalesUnitId": "",
"FixedExchangeRate": 0
}
Evidently we are hardcoding some values, and some we are passing as variables obtained from the above step (parse JSON step).
This will create the sales order with the payload as follows:
{
"@odata.context": "<base_url>/data/$metadata#SalesOrderHeadersV3/$entity",
"@odata.etag": "W/\"JzYxNTkwOTgwNiw2ODcxOTUyMjQwMTsxLDY4NzE5NDc4MjY0OzAsMDswLDA7MSw2ODcxOTQ3Njc3MzswLDA7MCwwOzAsMCc=\"",
"dataAreaId": "usmf",
"SalesOrderNumber": "000946",
"CustomerRequisitionNumber": "",
"SalesOrderProcessingStatus": "Active",
"OrderTotalAmount": 0,
"IntrastatPortId": "",
"ContactPersonId": "",
"CustomersOrderReference": "",
"SkipCreateAutoCharges": "Yes",
"TotalDiscountPercentage": 0,
"CustomerPaymentFineCode": "",
"IsSalesProcessingStopped": "Yes",
"InventoryReservationMethod": "Automatic",
"IntrastatTransportModeCode": "",
"InvoiceCustomerAccountNumber": "Cu00000111",
"URL": "",
"InvoiceAddressCity": "",
"BankSpecificSymbol": "",
"BaseDocumentNumber": "",
"IsFinalUser": "No",
"CFPSCode": "",
"InvoiceAddressStreet": "",
"InvoiceAddressCountyId": "",
"DeliveryAddressCountryRegionId": "",
"IsServiceDeliveryAddressBased": "No",
"InvoiceAddressDistrictName": "",
"InvoiceAddressTimeZone": null,
"FiscalOperationPresenceType": "DoesNotApply",
"MultilineDiscountCustomerGroupCode": "",
"IsOwnEntryCertificateIssued": "No",
"DeliveryAddressCountyId": "",
"DefaultShippingWarehouseId": "12",
"DeliveryAddressLocationId": "",
"CustomerPaymentMethodName": "",
"SalesUnitId": "",
"DefaultLedgerDimensionDisplayValue": "",
"DeliveryAddressCountryRegionISOCode": "",
"AreTotalsCalculated": "No",
"TaxExemptNumber": "",
"DeliveryAddressDescription": "",
"DeliveryAddressLongitude": 0,
"DefaultShippingSiteId": "1",
"CashDiscountCode": "",
"DeliveryReasonCode": "",
"TotalDiscountCustomerGroupCode": "",
"CampaignId": "",
"OrderTotalDiscountAmount": 0,
"PaymentTermsName": "",
"ShippingCarrierServiceGroupId": "",
"CIPEcode": "",
"RequestedReceiptDate": "2025-02-15T12:00:00Z",
"ConfirmedReceiptDate": "2025-02-15T12:00:00Z",
"BaseDocumentDate": "1900-01-01T12:00:00Z",
"EInvoiceDimensionAccountCode": "",
"OrderingCustomerAccountNumber": "Cu00000111",
"OrderTotalChargesAmount": 0,
"SalesRebateCustomerGroupId": "",
"TransportationBrokerId": "",
"DirectDebitMandateId": "",
"CreditNoteReasonCode": "",
"IntrastatStatisticsProcedureCode": "",
"TMACustomerGroupId": "",
"ArePricesIncludingSalesTax": "No",
"IsExportSale": "No",
"InvoicePaymentAttachmentType": "None",
"ReportingCurrencyFixedExchangeRate": 0,
"IsDeliveryAddressPrivate": "No",
"DeliveryAddressCity": "",
"DeliveryAddressStreet": "",
"NumberSequenceGroupId": "",
"OrderTotalTaxAmount": 0,
"DeliveryTermsCode": "",
"ChargeCustomerGroupId": "",
"WillAutomaticInventoryReservationConsiderBatchAttributes": "No",
"SalesTaxGroupCode": "",
"IsInvoiceAddressPrivate": "No",
"ThirdPartySalesDigitalPlatformCNPJ": "",
"OrderHeaderTaxAmount": 0,
"FiscalDocumentOperationTypeId": "",
"OrderCreationDateTime": "2025-02-24T02:59:07Z",
"SalesOrderOriginCode": "",
"ServiceFiscalInformationCode": "",
"DeliveryAddressStateId": "",
"FulfillmentPolicyName": "",
"CommissionSalesRepresentativeGroupId": "",
"CustomerPostingProfileId": "GEN",
"CustomerTransactionSettlementType": "None",
"BaseDocumentItemNumber": "",
"TransportationDocumentLineId": "00000000-0000-0000-0000-000000000000",
"DeliveryAddressStreetInKana": "",
"CustomerPaymentFinancialInterestCode": "",
"PaymentScheduleName": "",
"InvoiceAddressStreetNumber": "",
"SalesOrderStatus": "None",
"PaymentTermsBaseDate": "1900-01-01T12:00:00Z",
"ShippingCarrierId": "",
"InvoiceAddressPostBox": "",
"ConfirmedShippingDate": "2025-02-15T12:00:00Z",
"TenderCode": "",
"DeliveryAddressDunsNumber": "",
"IsEntryCertificateRequired": "No",
"ThirdPartySalesDigitalPlatform": "No",
"DeliveryAddressDistrictName": "",
"SalesOrderPromisingMethod": "None",
"DeliveryModeCode": "",
"BaseDocumentLineNumber": 0,
"TransportationModeId": "",
"SalesOrderName": "Test customer 2",
"DeliveryAddressStreetNumber": "",
"InvoiceAddressLongitude": 0,
"InvoiceAddressLatitude": 0,
"BaseDocumentType": "None",
"SalesOrderPoolId": "",
"FormattedInvoiceAddress": "",
"CustomerPaymentMethodSpecificationName": "",
"CurrencyCode": "USD",
"FormattedDelveryAddress": "",
"BankConstantSymbol": "",
"PriceCustomerGroupCode": "",
"DeliveryAddressTimeZone": null,
"FullRunCTPStatus": "Ready",
"Email": "",
"ExcludeFromMasterPlanning": "No",
"InvoiceAddressCityInKana": "",
"InvoiceAddressCountryRegionISOCode": "",
"TransportationTemplateId": "",
"IsConsolidatedInvoiceTarget": "No",
"OrderOrAgreementCode": "",
"TransportationRoutePlanId": "",
"FixedDueDate": "1900-01-01T12:00:00Z",
"DeliveryAddressName": "Test customer 2",
"ExportReason": "",
"FixedExchangeRate": 0,
"IntrastatTransactionCode": "",
"InvoiceAddressStreetInKana": "",
"InvoiceBuildingCompliment": "",
"RetailChannelTable": 0,
"InvoiceAddressZipCode": "",
"TotalDiscountAmount": 0,
"ShippingCarrierServiceId": "",
"IsOneTimeCustomer": "No",
"DeliveryAddressZipCode": "",
"OrderTakerPersonnelNumber": "",
"DeliveryAddressCityInKana": "",
"DeliveryAddressPostBox": "",
"IsDeliveryAddressOrderSpecific": "No",
"InvoiceAddressStateId": "",
"RequestedShippingDate": "2025-02-15T12:00:00Z",
"DeliveryAddressLatitude": 0,
"DeliveryBuildingCompliment": "",
"InvoiceAddressCountryRegionId": "",
"IsEInvoiceDimensionAccountCodeSpecifiedPerLine": "No",
"InvoiceType": "Invoice",
"EUSalesListCode": "IncludeNot",
"ProjectId": "",
"OverrideSalesTax": "No",
"QuotationNumber": "",
"OrderResponsiblePersonnelNumber": "",
"CommissionCustomerGroupId": "",
"LanguageId": "en-us",
"LineDiscountCustomerGroupCode": "",
"ShippingCarrierCustomerAccountNumber": "",
"SubBillCreatedFromSubscriptionBilling": "No",
"RevRecReallocationId": "",
"RevRecFollowOriginalPricingMethod": "No",
"RevRecMultipleSOReallocation": "No",
"RevRecContractEndDate": "1900-01-01T12:00:00Z",
"RevRecLatestReverseJournal": 0,
"RevRecContractStartDate": "1900-01-01T12:00:00Z",
"SkipGlobalUnifiedPricingCalculation": "No"
}
That’s it: our sales order has got created in this step. We would need the sales Id, and hence we are creating a variable called SalesId, which we are getting from the JSON response above:
To which we are again calling the Sales Line entity:
And in the body we are passing on the all the variables from the above step, some we are hardcoding. As this is the first line, hence we are not assigning the Line number explicitly. Sales Id, which we are getting from the above step, we are assigning it here:
And then we are returning thee sales Id generated to the Copilot as a last step of the flow:
Step 4
This is exactly what we are doing here back in our Copilot Studio:On getting the response from Flow, we are displaying as a response to the user.
Next we are asking the user the question, if he wants to add more lines:
Where Consent is a custom entity which I have created previously for obtaining the user input. If the User chooses OK, it will create transfer the call to another Topic. Else it will end the conversation, there itself:
Where evidently ‘Add more sales lines’ is my new topic to transfer, and I am passing my newly created SalesId and SalesOrderDetails variables to this topic.
This you can do by configuring the topic to accept variables as:
And then marking the variable to accept values from other topic:
And here also I am calling another flow, which is inserting more lines to sales line (just like we did in the previous step).
Except that, we need to take care of the sales line number here. The sales line number must be increased by one, before insert. For that we need to get the max of Line number till the last sales line inserted:
<Base_url>/data/SalesOrderLines?cross-company=true&$top=1&$select=LineNumber&$filter=SalesOrderNumber eq '' and dataAreaId eq ''
This is something like:
Select maxof(LineNum) from salesLine where salesline.salesId == <some_number>
And then while inserting in the sales line entity, we are increasing it by one:
And back in the Copilot I am recursively calling the sales line topic like this:
Which the copilot assesses by calling it back again and again:
Thus the user could keep on adding more and more lines to the sales order, as long as he is not choosing No – when the cycle breaks, and the Copilot responds back:
In the above step, I have added message variations which will make the Copilot respond with new responses, as the user chooses to conclude the conversation.
Let me conclude the discussion here. Please try the same at your end and let me know how it goes.
Signing off for now, much love and Namaste 😊 😊
*This post is locked for comments