The Client API object model for model-driven apps provides you objects and methods that you can use to apply custom business logic in model-driven apps using JavaScript, such as:
- Get or set attribute values.
- Show and hide user interface elements.
- Reference multiple controls per attribute.
- Access multiple forms per entity.
- Manipulate form navigation items.
- Interact with the business process flow control.
Root objects in the Client API object model
At the root of the Client API object model are the following contexts and the Xrm object:
Context which is passed when an event occurs on a form or grid which you can use it in your event handler to determine formContext, gridContext or manage the save event . It can be passed ext through UI or code:
Pass through UI – The execution context is an optional parameter that can be passed to a JavaScript library function through an event handler. Use the Pass execution context as first parameter option in the Handler Properties dialog while specify the name of the function to pass the event execution context. The execution context is the first parameter passed to a function.

Pass through code – Event handlers which cannot be defined from UI, can be defined from code. The execution context is automatically passed as the first parameter to functions set using code. For example:
addOnChange – formContext.getAttribute(arg).addOnChange(myFunction)
removeOnChange – formContext.getAttribute(arg).removeOnChange(myFunction)
FUNCTION MYFUNCTION(EXECUTIONCONTEXT)
{
//FIRST PARAMETER PASSED AS EXECUTION CONTEXT
}
Previously
function displayName()
{
var firstName = Xrm.Page.getAttribute(“firstname”).getValue();
var lastName = Xrm.Page.getAttribute(“lastname”).getValue();
console.log(firstName + ” ” + lastName);
}
Now
function displayName(executionContext)
{
var formContext = executionContext.getFormContext(); // get formContext
// use formContext instead of Xrm.Page
var firstName = formContext.getAttribute(“firstname”).getValue();
var lastName = formContext.getAttribute(“lastname”).getValue();
console.log(firstName + ” ” + lastName);
}
Form Context
provides a reference to the form or to an item on the form, such as, a quick view control or a row in an editable grid, against which the current code is executed.
Earlier, the global Xrm.Page object was used to represent a form or an item on the form. With the latest version, the Xrm.Page object is deprecated, and you should use the getFormContext method of the passed in execution context object to return reference to the appropriate form or an item on the form.
Use the data and ui objects under the formContext object to programmatically manipulate data and user interface elements in model-driven apps.

Grid Context
Context provides reference to grid or sub-grid on form against which code is executed. Grid context can be retrieved from execution context based on where code is being executed. Grid context also replaced Xrm.Page which was used to represent grid or sub grid on form earlier.
Previously
function doSomething()
{ var contactsSubgrid = Xrm.Page.getControl(“Contacts”);
}
Now
1) Code is executed on form event
function doSomething(executionContext)
{ var formContext = executionContext.getFormContext();
// get the form Context
var gridContext = formContext.getControl(“Contacts”);
// get the grid context
// Perform operations on the subgrid
}
2) Code is executed on grid event
function doSomething(executionContext)
{
var formContext = executionContext.getFormContext();
// get the form Context
var gridContext = formContext.getControl(“Contacts”);
// get the grid context
// Perform operations on the subgrid
}
Previously
Xrm.Page.getControl(“Contacts”).getGrid(); // Grid
Xrm.Page.getControl(“Contacts”).getGrid().getRows(); // GridRows
Xrm.Page.getControl(“Contacts”).getGrid().getRows(); // GridRowData
Xrm.Page.getControl(“Contacts”).getGrid().getRows().get(0).getEntity() // GridEntity
Now
gridContext.getGrid();
gridContext.getGrid().getRows();
gridContext.getGrid().getRows().get(0).data
gridContext.getGrid().getRows().get(0).entity
Xrm Object
Xrm object is globally available which provides methods to use device capabilities, navigation settings, information specific to organization or user and offline capabilities without having to use execution context in Client API. In this release Xrm object is updated to have new namespaces and new APIs in existing namespaces.

Device – Provides methods to use native device capabilities of mobile devices.
- captureAudio
- captureImage
- captureVideo
- getBarcodeValue
- getCurrentPosition
- pickFile
Encoding – Provides methods to encode strings.
- xmlAttributeEncode
- xmlEncode
Navigation – Provides methods for navigating forms and items in Customer Engagement.
- openAlertDialog
- openConfirmDialog
- openErrorDialog
- openFile
- openForm
- openUrl
- openWebResource
WebApi – Provides methods to use Web API to create, manage records and execute Web API actions and functions. Comes with offline capabilities also for mobile clients.
Properties:
online – perform actions or functions when connect to server (online mode)
offline – perform actions or functions when offline with mobile clients
Methods:
- createRecord – Creates an entity record
- deleteRecord – Deletes an entity record
- retrieveRecord – Retrieves an entity record
- retrieveMultipleRecords – Retrieves a collection of entity records
- updateRecord – Updates an entity record
- isAvaiableOffline – Returns a boolean value indicating whether an entity is present in user’s profile and is currently available for use in offline mode
- execute – Execute a single action, function, or CRUD operation
- executeMultiple – Execute a collection of action, function, or CRUD operations
Source: https://docs.microsoft.com/en-gb/powerapps/developer/model-driven-apps/clientapi/understand-clientapi-object-model