Tuesday, March 26, 2024

Dynamics 365 CE: Set and clear notification on a field using JavaScript

The following JavaScript code can be used to set and clear notification on a field.

formContext.getControl("attributename").setNotification("Message");                            
formContext.getControl("attributename").clearNotification();


formContext.ui.setFormNotification("Your message", "WARNING", "MessageID001");
formContext.ui.clearFormNotification("MessageID001");

Regards,

Arun S Keerthi

Monday, March 25, 2024

Dynamics 365 CE: Set lookup field value from a related record using JavaScript

 The following JavaScript code can be used to set a lookup field's value by retrieving the record from the child table and assign it to the parent table's related field on a form. 


Xrm.WebApi.retrieveRecord(entityName, '00000000-0000-0000-0000-000000000001', "?$select=field_name")
                .then(
                    function success(result1) {                                                                                                
                        var lookupValue             = new Array();
                        lookupValue[0]              = new Object();                        
                        lookupValue[0].id           = LookupFieldId;
                        lookupValue[0].name         = result1.field_name;
                        lookupValue[0].entityType   = "LookupEntityName";
                       
                        formContext.getAttribute("FormLookupAAttributeName").setValue(lookupValue);                            
                    },
                    function (error) {
                        console.log(error.message);
                    }
                );

Regards,

Arun S Keerthi

Dynamics 365 CE: Set a field visible using JavaScript

The following JavaScript code can be used to make a field Visible in Dynamics 365 app. 


function showField(executionContext){
    var formContext = executionContext.getFormContext();

    var attributename = formContext.getAttribute("attributename");

    if (attributename == true){
        formContext.getControl("attributename1").setVisible(false);
    }

}

Monday, February 19, 2024

Dynamics 365 F&O: Steps to import Database backup into Dev VM machine

This post describes the steps that are followed to restore UAT/Sandbox database (*.bacpac) into Azure Dev virtual machine.

 1. Download *.bacpac file from LCS.

LCS-> Select the project-> Shared Asset Library-> Database backup-> click the respective database file.

It will download the *. bacpac file

2. Save the db backup file in the dev machine's local folder for import.

3.Install SQL Package file in the dev machine.

Download and install SqlPackage - SQL Server | Microsoft Learn

4. Extract the SQL package zip

5. Open CMD prompt as an admin.

6. Navigate to SQL package folder

cd folder_path

7. Execute the following sql package import command.

SqlPackage.exe /a:import /sf:C:\Users\Admin1234\Documents\Backup\dbbackup.bacpac /tsn:localhost /tdn:AXDB_UAT /p:CommandTimeout=1200 /TargetEncryptConnection:False

8. Shrink the current DB's log file

ALTER DATABASE AxDB SET RECOVERY SIMPLE;
USE AxDB;
GO
CHECKPOINT;
GO
DBCC SHRINKFILE(AxDBCopy3_log, 1000); -- 1000 = 1GB
GO

9. After import rename restored DB's name as AxDB


USE master;  
GO  
ALTER DATABASE AxDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE AxDB MODIFY NAME = AxDB_Orig;
GO  
ALTER DATABASE AxDB_Orig SET MULTI_USER;
GO
USE master;  
GO  
ALTER DATABASE AxDB0906 SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE AxDB_UAT MODIFY NAME = AxDB;
GO  
ALTER DATABASE AxDB SET MULTI_USER;
GO

10. Synchronize the application with the DB using Visual Studio


Regards,
Arun S Keerthi











 

Friday, February 16, 2024

Dynamics 365 F&O - Setup Azure Dev Machine for Development

 In this blog I have shared the steps that are required to setup Dynamics 365 F&O Azure VM for development.

1. Connect to your Azure DEV virtual machine using Admin credentials. You can find the VM details in LCS > Cloud hosted environment. 

Note: You must be Environment Manager in order to see the credentials. Otherwise, please contact your LCS Administrator. 

2. Remote to Azure Dev VM and Open Visual Studio. 

Dev machine comes with Visual Studio and SSMS installed on the machine. 

3. Open Visual Studio as an Admin. Enter your Active Directory credentials to access VS. 

4. Connect Azure DevOps using Team explorer.

Enter the Azure DevOps URL. 

5. Map Azure DevOps' Metadata with K:\AosService\PackagesLocalDirectory and

map Project folder with Visual Studio project folder C:\Users\Adminf33bea59b8\Documents\Visual Studio 2022\Code Snippets\Projects.

   This will bring all the latest changes from Azure DevOps.

6. Refresh models.

VS -> Dynamics 365 -> Model Managment -> Refresh Model.

This will bring all the models that are used in the project from Azure DevOps.

7. Build Models

VS -> Dynamics 365 -> Build Models

8. Synchronize Database 

VS -> Dynamics 365 -> Synchronize Database


Regards,

Arun S Keerthi

Friday, October 4, 2019

Dynamics 365 F&O Application stack

The following picture shows the Dynamics 365 Finance & Operations Application stack hierarchy,






Friday, September 27, 2019

D365 Finance & Operation - Sample customization using ExtensionOf


Sample customization in D365 using Visual Studio, ExtensionOf attribute for beginners.

Note : I used VHD so I'm skipping LCS part.

Step 1: Open Visual studio as Admin

Step 2 : Create model



 
Step 3 : Select "Create new package"

Step 4 : I selected ApplicationPlatform, ApplicationSuite,ApplicationFoundation and Retail packges. You can select whatever you want based on your requirement.

Step 5 : Create new Unified Operations project
                                   

Step 6 : Create new class

                                   


Step 7 : Add following code, I added info log in run() to display the sales order id, by extending SalesTable form and build the project.

[ExtensionOf(formStr(SalesTable))]
final class SalesTable_Extension
{
void run()
    {
        next run();
        info ("Sales Order "+SalesTable.salesId);
    }

}

Step 8 : To test the code, open the F&O and go to Sales order and select any Sales id.



That's it.

Happy Daxing,

Regards,
Arun S. Keerthi