Using the new features – Create a formula (preview) and Explain this formula we can now easily write, edit, and understand formulas in Power Apps.
To enable it, navigate to switch on – Settings >> Updates >> Preview >> Copilot for formulas
Here in the sample app below, we are trying to set the Items property of the Gallery using Create a formula. Here our gallery control is bound to Cases as the data source.
We can describe what formula we need in plain language.
We can see it generating the formula for us. We have the option to Apply, Discard, and Copy it.
Here we have applied the generated formula.
Another example is where we are setting the Text property.
Here instead of the customer name it considered the Customer Contacted field. So basically we need to review the formula generated.
We can also generate formula from code comments as show below. Simply type the comment and wait for formula to be generated or otherwise press Enter.
The result
Next using Explain this formula we can use the copilot’s ability to explain the formula in plain language.
The result
We can also select specific parts of the formula for explanation.
Below we have selected the Filter keyword and Explain this selection option.
Field Suggestions by Copilot for Canvas Apps apply to Gallery, Form Table controls both classic and modern for Dataverse, SharePoint, or SQL Server data source. It analyzes the schema of the table selected and recommends up to 10 fields that also include a maximum of 10 required fields of that table.
Let us see it in action.
Below we have the following fields defined as required fields in the lead table.
Now inside CanvasApp when we insert and bind the Modern Form / Table or the classic Edit Form / Display Form, Data Table to the lead table it automatically suggests the fields for binding.
Here we have selected Lead as the Data Source for the Edit form or Form (modern) control.
Here we can see it suggesting all the required fields of the lead along with other key fields of lead like City, Country, Email, First Name, etc.
In the case of Table, we can see it suggesting the following 10 fields.
In the case of a custom table with very few fields in it, it suggested the below fields for Form and Table control.
To enable this feature navigate to Power Platform Admin Center > Environment > Features > Enable smart paste (preview)
With the smart paste feature, we can copy the text to the clipboard that has the details we want to fill in for our form and click the smart paste button or use our normal CTRL + V. Copilot will analyze the pasted text and will provide suggestions for the different fields on the form.
Suppose we have copied the below text from an email received–
Below we have selected the Smart paste button.
We can see the notification that the Smart Paste is analyzing the clipboard data.
And can see it populating the suggestions for most of the fields from the text we had copied.
We can click on Accept all suggestions or select it for the individual fields.
On Accept all suggestions we can see the values auto-filled from the copied text in clipboard –
Suppose we want to add the Lead Type (a custom choice field) to the Marketing Form’s form / form settings (RTM).
Open the Form table for customization, here we need to add the field to below 2 forms.
Starting with the Form Settings form, drag the field to the form.
If we check the form now, it will ask us to add it to the main form.
Open the Information (Main) form, double click the field to add it. As the field will not render in the form designer, select the field from the Tree View, and Hide it.
Or we can also open the form in the classic designer, there we will be able to see the field.
On saving and publishing the change, we can see our Lead Type field appearing on the Form Designer.
We had mapped the primary field for deletion and the package was also showing success.
However back in our CRM / Sales Hub app, we saw that none of the records were deleted (total – 48999)
The reason it was showing success is that we had specified the Ignore Error option in our CDS Destination component.
Then we created 2 more records but didn’t specify the partition ID for them.
This time on the successful run of the package we can see those 2 new records getting deleted for which we didn’t specify any partition ID i.e. Test 1 and Test 2 records were deleted successfully.
If we check the Microsoft docs it mentions that we need to include the partition ID using the alternate key to delete those records using the DeleteMultiple request.
Could not find a way to specify an Alternate Key in the CDS Destination component for the Delete message and if we try deleting the records one by one instead of using the DeleteMultiple request we get the below error.
[CDS Destination [2]] Error: An error occurred with the following error message: “System.Exception: Error(s) occurred when processing the batch: [1] KingswaySoft.IntegrationToolkit.DynamicsCrm.WebAPI.WebApiServiceException: The remote server returned an error: (404) Not Found. (Error Type / Reason: NotFound, Detailed Message: {“error”:{“code”:”0x80040217″,”message”:”The HTTP status code of the response was not expected (404).\n\nStatus: 404\nResponse: \n{\”error\”:{\”message\”:\”Could not find item ‘b3a70971-9674-ef11-a671-6045bdfe58ee’.\”,\”details\”:[{\”message\”:\”\\r\\nErrors : [\\r\\n \\\”Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found\\\”\\r\\n]\\r\\n\”}]}}”}}) (SSIS Integration Toolkit for Microsoft Dynamics 365, v23.2.2.32701 – DtsDebugHost, v16.0.5270.0)System.Net.WebException
As expected, using CrmServiceClient also if we do not include partitionid we will get the below error for the records that have partition id specified.
The HTTP status code of the response was not expected (404).
Response:
{“error”:{“message”:”Could not find item ‘b3a70971-9674-ef11-a671-6045bdfe58ee’.”,”details”:[{“message”:”\r\nErrors : [\r\n \”Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found\”\r\n]\r\n”}]}}
Here we can specify the partitionId parameter to delete those records having the partitionId specified in the DeleteRequest
For DeleteMultiple Request we need to provide the alternate key as shown below.
We will have the alternate key auto-created by the system when we create an elastic table.
Sample Code –
var myServiceClient = new CrmServiceClient(connectionString);
var query = new QueryExpression("custom_myelastictable");
query.ColumnSet.AddColumns("custom_name", "partitionid");
var myElasticTableCollection = myServiceClient.RetrieveMultiple(query);
var lstEntityRefCollection = new EntityReferenceCollection();
// Delete Request
foreach (var elasticTable in myElasticTableCollection.Entities)
{
var deleteRequest = new DeleteRequest();
deleteRequest.Target = new EntityReference("custom_myelastictable", elasticTable.Id);
deleteRequest.Parameters["partitionId"] = elasticTable.Attributes["partitionid"];
var response = myServiceClient.Execute(deleteRequest);
}
// DeleteMultiple Request
foreach (var elasticTable in myElasticTableCollection.Entities)
{
var entityRef = new EntityReference("custom_myelastictable", elasticTable.Id);
entityRef.KeyAttributes.Add("custom_myelastictableid", elasticTable.Id);
entityRef.KeyAttributes.Add("partitionid", elasticTable.Attributes["partitionid"]);
lstEntityRefCollection.Add(entityRef);
}
var deleteMultipleRequest = new OrganizationRequest();
deleteMultipleRequest.RequestName = "DeleteMultiple";
deleteMultipleRequest.Parameters.Add("Targets", lstEntityRefCollection);
myServiceClient.Execute(deleteMultipleRequest);