diff --git a/xrm/xrm-tests.ts b/xrm/xrm-tests.ts
index 5b2d079f8..610662c7d 100644
--- a/xrm/xrm-tests.ts
+++ b/xrm/xrm-tests.ts
@@ -2,6 +2,8 @@
///
///
+/// Demonstrate clientglobalcontext.d.ts
+
function _getContext()
{
var errorMessage = "Context is not available.";
@@ -19,16 +21,17 @@ function _getContext()
var crmContext = _getContext();
-/// Delegate selector call into getControl
+/// Demonstrate iterator typing
+
var grids = Xrm.Page.getControl(( control ) =>
{
return control.getControlType() === "subgrid";
});
-/// Describing the shape of an array.
var selectedGridReferences: Xrm.Page.LookupValue[] = [];
-/// Dynamic casting into lambda, raising from Xrm.Page.Control to Xrm.Page.GridControl
+/// Demonstrate iterator typing with v7.1 additions
+
grids.forEach(( gridControl: Xrm.Page.GridControl ) =>
{
gridControl.getGrid().getSelectedRows().forEach(( row ) =>
@@ -37,43 +40,42 @@ grids.forEach(( gridControl: Xrm.Page.GridControl ) =>
})
});
-/// Working to a string attribute, through getControl
-var stringControlType = Xrm.Page.getControl( "new_someStringAttribute" );
-var stringAttribute = stringControlType.getAttribute();
+/// Demonstrate generic overload vs typecast
-stringAttribute.setValue( "New String Value" );
+var lookupAttribute = Xrm.Page.getControl( "customerid" );
+var lookupAttribute2 = Xrm.Page.getControl( "customerid" );
+/// Demonstrate ES6 String literal syntax
-
-/// Specialized control interfaces expose only appropriate members
-var lookupAttribute = Xrm.Page.getControl( "customerid" );
-
-/// ES6 String-literal style
lookupAttribute.addCustomFilter( `
`, "account" );
-/// Lambda event handler declaration
lookupAttribute.addPreSearch(() => { alert( "A search was performed." ); });
-/// Type inference by interface casts getAttribute and getValue appropriately
+/// Demonstrate strong-typed attribute association with strong-typed control
+
var lookupValues = lookupAttribute.getAttribute().getValue();
if ( lookupValues !== null )
if ( !lookupValues[0].id || !lookupValues[0].entityType )
throw new Error("Invalid value in Lookup control.");
-/// Working with the Business Process Flow API
+/// Demonstrate v7.0 BPF API
+
if (Xrm.Page.data.process != null)
Xrm.Page.data.process.moveNext(( status ) => { alert( `Process moved forward with status: ${status}` ) });
-/// Opening the QuickCreate form.
+/// Demonstrate v7.1 Quick Create form
+
Xrm.Utility.openQuickCreate(( newRecord ) => { alert( `Newly created record Id: ${newRecord.id}` ); }, "account" );
-/// Setting every control on the form to visible
+/// Make all controls visible.
+
Xrm.Page.ui.controls.forEach(( control ) => { control.setVisible( true ); });
-/// Setting every tab and section on the form to visible
+/// Make all tabs and sections visible.
+
Xrm.Page.ui.tabs.forEach(( tab ) =>
{
tab.setVisible( true );
@@ -84,16 +86,17 @@ Xrm.Page.ui.tabs.forEach(( tab ) =>
});
});
-/// OnSave handler with context
+/// Demonstrate OnSave event context.
+
Xrm.Page.data.entity.addOnSave(( context ) =>
{
var eventArgs = context.getEventArgs();
- /// Use of enumerations for more descriptive code
if ( eventArgs.getSaveMode() === Xrm.Page.SaveMode.AutoSave || eventArgs.getSaveMode() === Xrm.Page.SaveMode.SaveAndClose )
eventArgs.preventDefault();
});
+/// Demonstrate ES6 String literal with templates
alert( `The current form type is: ${Xrm.Page.ui.getFormType() }` );