Fixed – The reference assemblies for. NETFramework,Version=v4.6.2 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application


Recently while trying to use the Power Platform Toolshttps://learn.microsoft.com/en-us/power-apps/developer/data-platform/tools/devtools-install , got the below error in Visual Studio 2019. (not supported for VS 2022)


To fix it either you can, open Visual Studio Installer and select Modify and select the appropriate developer pack.



Or as specified in the error message, open https://aka.ms/msbuild/developerpacks, and download the appropriate Developer pack from there.


This fixed the issue –


Hope it helps..

Advertisements

Power Apps Component Life Cycle – Quick look


We can read about the architecture and the life cycle of the Power Apps component here.

Check the screencast – PowerApps Component Life Cycle

Let us see it in action using a sample project.

Launching the test harness, we can see the init executed followed by updateView.

Making any change in the component’s form factor, width, height, or Data Inputs property triggers the updateView method.

Now let us update the index.ts and add a textElement along with an event listener for its change event.

Inside the test harness, when we change the Value of the sampleProperty, if we want the value of the textElement to be updated, we need to use the updateView method to fetch the changed value from the bound sample property field and reflect this new data in the UI.

We can get the value of the sampleProperty from the context and use it to set the textElement value as shown below.

Now let us do the opposite, let us change the value inside the textElement. Here as expected none of the methods triggers.

Here we need to call the notifyOutputChanged method, to notify the host that the component’s output has changed.

On calling notifyOutputChanged, the framework runtime will first call getOutputs to get the value of the bound properties of the component, and then notifies the host.

The host will perform the validation and if the output received is valid it will call the updateView.

But before we do that let us first try setting the value of the sampleProperty in the change event handler of the textElement. Here on changing the value inside the text box, we can see only the change event handler is triggered. No other methods are triggered here as expected.

There is no update in the value of the bound sampleProperty.

This is because we need to call the notifyOutputChanged method to let the host know about the changes made in the value inside the text box.

On calling the notifyOutputChanged and changing the text value this time, we can see the getOutputs being called.

The value remains the same for the bound property and updateView method is not called as our getOutputs method was not returning anything.

Let us update the getOutputs method to return the sampleProperty having the text value.

On changing the textElement value this time getOutputs is called, followed by updateView.

To summarize,

  • To notify the host, about the user changes in the UI                                                ècall notifyOutputChanged
    è the framework will call the getOutputs
    è followed by èupdateView
  • Host changes the data/properties                                                               èupdateView will be called è context passed è we can update the UI as per our requirements

Check the following links to understand more about the life cycle –

https://dianabirkelbach.wordpress.com/2020/03/29/pcf-when-is-updateview-called/

https://dianabirkelbach.wordpress.com/2022/02/28/async-requests-inside-pcf-init-and-updateview/

To learn about PCF –

Getting started with PCF Custom Controls by Danish Naglekar

https://www.youtube.com/watch?v=ZYOHaHUf83Y

https://www.youtube.com/watch?v=o3OW6UW-RMI&list=PLqJfvq4Fy1P5TgPGm8Ny_legkZUk5BfyV&index=2

PCF Academy by Andrew Butenkohttps://www.youtube.com/watch?v=YJ9hrKxAhTU&list=PL0WiRFWRFGlQr5tGZdUGUlyTl7Gi1Wb_K

https://bgx.blob.core.windows.net/files/powerplatform/PCFControlGuide.pdf

Hope it helps..

Advertisements

How to – Clone a record in Dataverse / Dynamics 365 (C#)


Here we will be cloning the below contact record –

For it, we can make use Clone method of EntityExtensions class

If we run the below code, we will get the “Cannot insert duplicate key” exception.

Because we need to set the ID for the newly cloned record to either empty or a new GUID.

Also, we need to remove the contactid attribute or entity’s id field else we will get the below exception – “Entity Id must be the same as the value set in property bag

Also if we are retrieving all the attributes we need to make sure we remove those attribute which can cause below unique constraint errors.

Sql error: The operation attempted to insert a duplicate value for an attribute with a unique constraint. CRM ErrorCode: -2147012606 Sql ErrorCode: -2146232060 Sql Number: 2627

In case of contact, we had to remove the address id attributes, to get the record cloned.

Now let us clone the same contact record with its related leads.

  • Here first we need to retrieve contact along with its associated lead record.
  • Then remove the id attribute that could duplicate issues in the child lead records also.

Please refer the helpful posts –

https://debajmecrm.com/clone-record-dynamics-crm-clone-method/

https://www.inogic.com/blog/2014/08/clone-records-in-dynamics-crm/

https://dyncrmexp.com/2017/10/24/retrieve-primary-entities-along-with-related-entities-with-one-queryexpression/comment-page-1/

https://dynamict.eu/2016/08/09/create-record-with-related-records-in-a-single-request-using-c/

Hope it helps..

 // related lead records of contact
                    QueryExpression query = new QueryExpression("lead");                    
                    query.ColumnSet = new ColumnSet(true);

                    // contact and lead - 1 - n relationship
                    Relationship relationship = new Relationship("lead_parent_contact");
                    relationship.PrimaryEntityRole = EntityRole.Referenced;

                    RelationshipQueryCollection relatedEntity = new RelationshipQueryCollection();
                    relatedEntity.Add(relationship, query);

                    RetrieveRequest request = new RetrieveRequest();
                    request.RelatedEntitiesQuery = relatedEntity;
                    request.ColumnSet = new ColumnSet(true);
                    request.Target = new EntityReference("contact", new Guid("ca0aa844-57c6-ec11-a7b6-00224826af1e"));

                    RetrieveResponse response = (RetrieveResponse)svc.Execute(request);
                    var contactToBeCloned = response.Entity;                   
                    var clonedContact = contactToBeCloned.Clone(true);

                    // remove attribute that can cause error from main entity             
                    clonedContact.Id = Guid.NewGuid();
                    clonedContact.Attributes.Remove("contactid");                    
                    clonedContact.Attributes.Remove("address1_addressid");
                    clonedContact.Attributes.Remove("address2_addressid");
                    clonedContact.Attributes.Remove("address3_addressid");

                    // remove attribute that can cause error from child / related entities
                    foreach (var relatedEntities in clonedContact.RelatedEntities)
                    {
                        foreach(var leadEntity in relatedEntities.Value.Entities)
                        {
                            leadEntity.Id = Guid.NewGuid();
                            leadEntity.Attributes.Remove("leadid");
                            leadEntity.Attributes.Remove("address1_addressid");
                            leadEntity.Attributes.Remove("address2_addressid");
                        }
                    }
                    svc.Create(clonedContact);
Advertisements

How to –Upload files to File Column / Attribute in SSIS from Azure Blog Storage – KingswaySoft (Dynamics 365 / CRM)


Below are a few ways we can upload files to the File Column type field using KingswaySoft’ s Integration Toolkit and Premium Flat File Source and Premium Derived column which are part of the SSIS Productivity Pack of KingswaySoft

https://nishantrana.me/2022/03/17/how-to-upload-files-from-file-column-attribute-using-ssis-kingswaysoft-dynamics-365-crm/

Using the Import columnhttps://nishantrana.me/2022/08/10/how-to-upload-files-to-file-column-attribute-using-ssis-kingswaysoft-and-import-column-dynamics-365-crm/

Using the Script Componenthttps://nishantrana.me/2022/08/09/how-to-use-script-component-to-upload-files-to-file-column-attribute-in-ssis-kingswaysoft-dynamics-365-crm/

Here instead of uploading the files from the local drive, we will be uploading the files stored in the Azure Blob Storage to the corresponding contact records inside CRM.

Below is our Blob Container – here to make things simple we have the mobile number of the contact records used as the pdf file name uploaded, and which will be used for updating the contact records.

The contact records in CRM

Below is how our package looks like

Here we have specified the Item Selection Mode as Recursive (File Only) to make sure it picks the files only and not the folder.

Within the Derived Column, we are replacing the pdf extension from the file name i.e. mobile number, and using it to find the contact records and update them.

Finally, in the CDS / CRM Destination Component, we are performing an upsert using the dervied Mobile Phone Formatted derived column as a match.

The mapping –

Let us now run the package.

Let us now open the records and check.

As expected we can see the file uploaded.

Thanks to Venkata for this solution https://www.linkedin.com/in/venkata-satya-kumar-nagumalli-77923972

Also, check out –

To extract attachments from notes-https://nishantrana.me/2021/02/10/extracting-attachments-from-notes-in-dynamics-365-dataverse/

To download files using Download Block Requesthttps://nishantrana.me/2022/03/14/how-to-download-file-from-file-column-using-initializefileblocksdownload-and-downloadblock-request-dynamics-365-crm-dataverse/

To upload files using Upload Block Requesthttps://nishantrana.me/2022/03/15/how-to-upload-file-to-file-column-using-initializefileblocksupload-and-uploadblock-request-dynamics-365-crm/

Understand File and Image Data Typehttps://nishantrana.me/2021/10/01/using-file-and-image-data-type-in-dataverse-dynamics-365/

Try out the wonderful, feature-rich, and powerful SSIS Integration Toolkit for Dynamics 365 by KingswaySofthttps://www.kingswaysoft.com/products/ssis-integration-toolkit-for-microsoft-dynamics-365/download

Check other articles on SSIS plus CRM – https://nishantrana.me/2018/11/26/ssis-and-microsoft-dynamics-365/

Hope it helps..

Advertisements

Environment Variable referencing Azure Key Vault secrets (Dataverse / Power Platform)


Check out the below articles –

https://docs.microsoft.com/en-us/power-apps/maker/data-platform/environmentvariables#use-azure-key-vault-secrets-preview

Within plugin https://itmustbecode.com/azure-key-vault-secrets-in-dataverse/

Within Power Automatehttps://www.msautomate.com/2022/06/16/azure-keyvault-and-power-automate/

https://powerapps.microsoft.com/en-us/blog/how-to-use-environment-variables-with-akv-secrets-in-the-ci-cd-pipeline-when-deploying-applications/

https://blog.yannickreekmans.be/environment-variable-secrets-azure-key-vault-improvement/

Advertisements

How to – Use Import Column to Upload files to File Column / Attribute in SSIS KingswaySoft(Dynamics 365 / CRM)


A few weeks back had posted on how to upload files to the File Column type field using KingswaySoft’ s Integration Toolkit and Premium Flat File Source and Premium Derived column which are part of the SSIS Productivity Pack of KingswaySoft

https://nishantrana.me/2022/03/17/how-to-upload-files-from-file-column-attribute-using-ssis-kingswaysoft-dynamics-365-crm/

Here we will see an example of achieving the same without using the KingswaySoft Productivity Pack’s Premium Flat File Source and Derived column. (although would recommend using it as it includes over 300 premium components making it easier to rapidly build efficient solutions)

https://www.kingswaysoft.com/products/ssis-productivity-pack

Below is our source file

The contact records in CRM

Below is how the package looks like

The Flat File Source points to the location where we have the source csv file containing email, file path, and file name.

Import Column takes the File Path as the Input.

For the Input and Output properties, add an output column (BinaryColumn) of DataType = image.

In the FilePath input column properties, specify the column id of the output column.

Finally, in the CDS / CRM Destination Component, we are performing an upsert using the Email id as a match.

Here we have mapped the output column of the Import Column i.e. BinaryColumn to the binary content field of the file type attribute of the CRM.

Let us now run the package.

Let us now open the records and check.

As expected we can see the file uploaded.

Also, check out –

To extract attachments from notes-https://nishantrana.me/2021/02/10/extracting-attachments-from-notes-in-dynamics-365-dataverse/

To download files using Download Block Requesthttps://nishantrana.me/2022/03/14/how-to-download-file-from-file-column-using-initializefileblocksdownload-and-downloadblock-request-dynamics-365-crm-dataverse/

To upload files using Upload Block Requesthttps://nishantrana.me/2022/03/15/how-to-upload-file-to-file-column-using-initializefileblocksupload-and-uploadblock-request-dynamics-365-crm/

Understand File and Image Data Typehttps://nishantrana.me/2021/10/01/using-file-and-image-data-type-in-dataverse-dynamics-365/

Try out the wonderful, feature-rich, and powerful SSIS Integration Toolkit for Dynamics 365 by KingswaySofthttps://www.kingswaysoft.com/products/ssis-integration-toolkit-for-microsoft-dynamics-365/download

Check other articles on SSIS plus CRM – https://nishantrana.me/2018/11/26/ssis-and-microsoft-dynamics-365/

Hope it helps..

Advertisements
%d bloggers like this: