Updating a record from JavaScript using the Xrm.WebAPi in Dynamics 365 V9

Summary : Updating a record from JavaScript using the Xrm.WebAPi in Dynamics 365 V9


Now let’s update a record
Syntax: Xrm.WebApi.updateRecord(entityLogicalName, id, data).then(successCallback, errorCallback);

***Code starts here***

var entityData =
                {
                    "subject": “leadFromWebApi_Updated”,
                    "lastname": “RamLaxman”
                }

Xrm.WebApi.createRecord("lead", id, entityData).then(
                    function success(result)
                    {
                        alert("Record updated successfully ");                      
                    },
                    function (error)
                    {
                        console.log(error.message);       
                    });
***Code ends here***

Creating a record from JavaScript using the Xrm.WebAPi in Dynamics 365 V9

Create Record:

Let’s see how we can create a “Lead” record using newly introduced
 Web API calls in Dynamics 365 V9
Xrm.WebApi.createRecord(“entityLogicalName”,data).then(successCallback,errorCallback);
// This line of code is required if you are creating from HTML webresource.

<script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>

var entityData =


                {
                    "subject": “leadFromWebApi”,
                    "lastname": “Ram”
                }


Xrm.WebApi.createRecord("lead", entityData).then(
                    function success(result)
                    {
                        alert("Record Created successfully and Id is: " + result.id);
                        console.log("Account created with ID: " + result.id);
                    },
                    function (error)
                    {
                        console.log(error.message);       
                    });



How to Download Plugin Registration Tool from nuget Using Power Shell Script in Dynamics 365 Version 9.x

Summary :  How to Download Plugin Registration Tool Using Power Shell Script in Dynamics 365 Version 9.x 

1. Start menu, Search for Windows Powershell and open.
2. Navigate to the folder you want to install the tools to. For example (d:/Tools)
3. Execute the following Script

$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$targetNugetExe = ".\nuget.exe"
Remove-Item .\Tools -Force -Recurse -ErrorAction Ignore
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
Set-Alias nuget $targetNugetExe -Scope Global -Verbose

##
##Download Plugin Registration Tool
##
./nuget install Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool -O .\Tools
md .\Tools\PluginRegistration
$prtFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool.'}
move .\Tools\$prtFolder\tools\*.* .\Tools\PluginRegistration
Remove-Item .\Tools\$prtFolder -Force -Recurse




Virtual Entity feature in Dynamics 365 V9.x Part 2




Create a Virtual Entity Data Source
Login to Dynamics 365 click Settings -> Administration and then Virtual Entity Data Source to open the Data Sources grid.



In the Data Sources grid click on New, to open the Select Data Provider window



In Select Data Provider window select OData v4 Data Provider and then click OK to open the New OData v4 Data Source dialog





Create a Virtual Entity

Now, let’s create a virtual entity to bring data from the OData Source. Click Settings -> Administration -> Customize the System


Create a virtual entity like custom entity and select the Virtual Entity checkbox.



Popular Posts