Search This Blog

Thursday, November 23, 2017

Open Lookup window in CRM V9.0

XRM.Utlity

Property Name
Type
Required
Description
allowMultiSelect
Boolean
No
Indicates whether the lookup allows more than one item to be selected.
defaultEntityType
String
No
The default entity type to use.
defaultViewId
String
No
The default view to use.
entityTypes
Array
No
The entity types to display.
showBarcodeScanner
Boolean
No
Indicates whether the lookup control should show the barcode scanner in mobile clients.
viewIds
Array
No
The views to be available in the view picker. Only system views are supported.

Xrm.Utility.lookupObjects(lookupOptions).then(successCallback, cancelCallback)
var lookupOptions =new Object();
lookupOptions.allowMultiSelect=false
lookupOptions.defaultEntityType='contact'
var arr=new Array()
arr.push('A2D479C5-53E3-4C69-ADDD-802327E67A0D')
lookupOptions.viewIds=arr

lookupOptions.defaultViewId='A2D479C5-53E3-4C69-ADDD-802327E67A0D'

var arr2=new Array();
arr2.push('contact');
lookupOptions.allowMultiSelect=false;
lookupOptions.entityTypes=arr2;
Xrm.Utility.lookupObjects(lookupOptions).then(successCallback, cancelCallback)
function successCallback(objResult){debugger;

}
function cancelCallback(){}






















Dynamics CRM 365 V9.0-Client Side Development features-Part2

CRM 2016
V9.0
Xrm.Page
ExecutionContext.getFormContext (Special rules apply to this)
Xrm.Page.context
Xrm.Utility.getGlobalContext
Xrm.Page.context.getQueryStringParameters
formContext.data.attributes
Xrm.Page.context.getTimeZoneOffsetMinutes
globalContext.userSettings.getTimeZoneOffsetMinutes
Xrm.Page.context.getUserId
globalContext.userSettings.userId
Xrm.Page.context.getUserLcid
globalContext.userSetings.languageId
Xrm.Page.context.getUserName
globalContext.userSettings.userName
Xrm.Page.context.getUserRoles
globalContext.userSettings.securityRoles
Xrm.Page.context.getIsAutoSaveEnabled
globalContext.organizationSettings.isAutoSaveEnabled
Xrm.Page.context.getOrgLcid
globalContext.organizationSettings.languageId
Xrm.Page.context.getOrgUniqueName
globalContext.organizationSettings.uniqueName
Xrm.Page.data.entity.save(string)
Xrm.Page.data.entity.save(saveOptions)
Xrm.Page.data.entity.getDataXml
No changes in addition to using type names rather than type by lookup fields
GridRow.getData
GridRow.data
GridRowData.getEntity
GridRowData.entity
Xrm.Mobile.offline
Xrm.WebApi.offline
parent.Xrm
Brug HTML web resource
addOnKeyPress
Use a Custom Control
removeOnKeyPress
Use a Custom Control
showAutoComplete
Use a Custom Control
hideAutoComplete
Use a Custom Control
Xrm.Utility.alertDialog
Xrm.Navigation.openAlertDialog
Xrm.Utility.confirmDialog
Xrm.Navigation.openConfirmDialog()
Xrm.Utility.isActivityType
Xrm.Utility.getEntityMetadata
Xrm.Utility.openEntityForm
Xrm.Navigation.openForm
Xrm.Utility.openQuickCreate
Xrm.Navigation.openForm
Xrm.Utility.openWebResource
Xrm.Navigation.openWebResource
Thanks to Henrik Jensen
http://crmblog.dk/post/2017/07/09/Dynamics-365-v9-API-relateret-funktionalitet-som-udgar.aspx

Dynamics CRM 365 V9.0- Client Side Development features-Part1

New Client API in Dynamcis CRM V9.0

Xrm.UtilityShowProgressIndicator
Display the progress dialog

This dialog message also update for the subsequent request.



Xrm.Utility.showProgressIndicator(message)

To close progress dialog
Xrm.Utility.closeProgressIndicator()

Xrm.Utility.lookupObjects(lookupOptions).then(successCallback, cancelCallback)
var lookupOptions =new Object();
lookupOptions.allowMultiSelect=false
lookupOptions.defaultEntityType='contact'
var arr=new Array()
arr.push('A2D479C5-53E3-4C69-ADDD-802327E67A0D')
lookupOptions.viewIds=arr

lookupOptions.defaultViewId='A2D479C5-53E3-4C69-ADDD-802327E67A0D'

var arr2=new Array();
arr2.push('contact');
lookupOptions.allowMultiSelect=false;
lookupOptions.entityTypes=arr2;
Xrm.Utility.lookupObjects(lookupOptions).then(successCallback, cancelCallback)
function successCallback(objResult){debugger;

}
function cancelCallback(){}


Xrm.Utility.getEntityMetadata('account')
Get the entity metadata based on the attribute

var arr=new Array();
arr.push('fullname');
Xrm.Utility.getEntityMetadata("contact",arr).then(successCallback, errorCallback)


Xrm.Utility.invokeProcessAction(name,parameters).then(successCallback, errorCallback)

Call the action from client side

parameter:
 It is an object with key value pair where key is a string

Xrm.Utility.invokeProcessAction(name,parameters).then(successCallback, errorCallback)

Xrm.Utility.getGlobalContext().userSettings
Get the CRM logged in user information

var userSettings = Xrm.Utility.getGlobalContext().userSettings;


 Xrm.Utility.getGlobalContext().organizationSettings

var organizationSettings = Xrm.Utility.getGlobalContext().organizationSettings

organizationSettings.uniqueName
organizationSettings.organizationId
organizationSettings.languageId

Xrm.Panel.loadPanel(url, title)
Xrm.Panel.loadPanel('https://octmid.crm.dynamics.com/main.aspx?etc=1&extraqs=&histKey=597090480&id=%7b80DBEA7A-C5CA-E711-A94F-000D3A34AFA9%7d&newWindow=true&pagetype=entityrecord&sitemappath=SFA%7cCustomers%7cnav_accts#698913490')




Xrm.WebApi
All the below request are  work only in "asynchronous"

Xrm.WebApi.createRecord(entityType,data)

//Create an account with lookup value set
var data =
    {
        "name": "TestData",
        "primarycontactid@odata.bind": "/contacts(321b158c-841c-e511-80d3-3867eb348ba8)"
    }

// create account record
Xrm.WebApi.createRecord("account", data).then(
    function success(result) {
        console.log("Account created with ID: " + result.id);
        // perform operations on record creation
    },
    function (error) {
        console.log(error.message);
        // handle error conditions
    }
);


Retrieve Record:
Xrm.WebApi.retrieveMultipleRecords

Xrm.WebApi.retrieveMultipleRecords("account", "?$select=name&$filter=name eq 'test'").then(
    function success(result) {
        for (var i = 0; i < result.entities.length; i++) {
            console.log(result.entities[i]);
        }                    
        // perform additional operations on retrieved records
    },
    function (error) {
        console.log(error.message);
        // handle error conditions
    }
);


Delete Record:
Xrm.WebApi.deleteRecord("account","38E44DF0-BFCA-E711-A94F-000D3A34AFA9")


Refer Link :https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-webapi/

Tuesday, November 21, 2017

Dynamics 365 V9.0 Multiselect option

Get Value from Multi select control
Xrm.Page.getAttribute('new_testmultiselect').getValue()

Set Value from Multi select control
var arr=new Array();
arr.push(100000002);
arr.push(100000001);

Xrm.Page.getAttribute('new_testmultiselect').setValue(arr)
or
Xrm.Page.getAttribute('new_testmultiselect').setValue([100000002,100000001])

Set null/empty Value from Multi select control
Xrm.Page.getAttribute('new_testmultiselect').setValue(null)

Multiselect control is not applicable for the following 

  • Set multiselect field values through the business rule
  • Set multiselect field values through a workflow