If you have any doubt in the post please post comments. I will try to solve your problem.
In this article , I am going to explain how to get current user roles
Current user roles
var UserRoles = Xrm.Page.context.getUserRoles();
Name | Type | Required | Description |
---|---|---|---|
name
|
String
|
Yes
|
The logical name of the entity.
|
id
|
String
|
No
|
The string representation of a unique identifier or the record to open in the form. If not set, a form to create a new record is opened.
|
parameters
|
Object
|
No
|
A dictionary object that passes extra parameters to the form. Invalid parameters will cause an error.
Valid extra query string parameters are:
|
windowOptions
|
Object
|
No
|
For Microsoft Dynamics CRM Online 2015 Update 1 or later use this optional parameter in the web application to control how the form opens. You can choose to open a form in a new window by passing a dictionary object with a Boolean openInNewWindowproperty set to true.
This parameter is ignored in CRM for tablets and CRM for phones.
|
Parameter | Description | ||
---|---|---|---|
etn
|
The logical name of the entity.
| ||
extraqs
|
Optional for forms. This parameter contains encoded parameters within this parameter.
Use this parameter to pass values to a form. For more information, see Set field values using parameters passed to a form.
When an entity has more than one form defined, you can use this parameter to specify which form to open by passing the encoded parameter
formid with the value equal to the ID value of the form. For example, to open a form with the ID of ‘6009c1fe-ae99-4a41-a59f-a6f1cf8b9daf’, include this value in the extraqs parameter: formid%3D6009c1fe-ae99-4a41-a59f-a6f1cf8b9daf%0D%0A . | ||
pagetype
|
The type of page. There are two possible values:
| ||
id
|
Optional for forms. Use this when you open a specific entity record. Pass in the encoded GUID identifier for the entity. The encoded version of the GUID substitutes opening and closing brackets “{“ and “}” with “%7B” and “%7D”, respectively, for example
{91330924-802A-4B0D-A900-34FD9D790829} is %7B91330924-802A-4B0D-A900-34FD9D790829%7D . | ||
viewid
|
Required for views. This is the ID of the savedquery or userquery entity record that defines the view. The easiest way to get the URL for a view is to copy it. For more information, see Copy the URL for a View.
| ||
viewtype
|
Defines the view type. Possible values are as follows:
| ||
navbar
|
Controls whether the navigation bar is displayed and whether application navigation is available using the areas and subareas defined in the sitemap.
| ||
cmdbar
|
Controls whether the command bar is displayed.
|
Name | Type | Required | Description |
---|---|---|---|
webResourceName
|
String
|
Yes
|
The name of the HTML web resource to open.
|
webResourceData
|
String
|
No
|
Data to be passed into the data parameter.
|
width
|
Number
|
No
|
The width of the window to open in pixels.
|
height
|
Number
|
No
|
The height of the window to open in pixels.
|
// Put this in onload
window.onbeforeunload = function()
{
alert("unload event")
}
var _mode = event.Mode;
alert("Save event .. with mode : " +_mode);