Common JS for Dynamics Crm

Source: Internet
Author: User

Experienced 3 Dynamics CRM projects, write some common JS ~~!

Common JS (one)

Xrm.Page.context.getUserId ();//get Current User ID

Xrm.Page.context.getUserName ();//Get the user name of the current user

Xrm.Page.data.entity.getId (); Gets the current record ID

Xrm.Page.context.getUserRoles (); Gets the security role when the user

Xrm.Page.context.getUser (); Get Current User

Xrm.Page.getAttribute ("name"). GetValue (); Gets the field value of the field named "Name" ( Note: If the child layer gets the field of the parent layer, the statement is Parent.window)

Xrm.Page.getAttribute ("name"). SetValue ("Inputer"); Assign a value to a field named "Name"

Xrm.Page.getAttribute ("name"). Setsubmitmode ("Inputer"); Automatically submit a field named "Name" after it is assigned a value

Xrm.Page.getControl ("St_portfoliomanager"). setvisible (false); Hide a field named "St_portfoliomanager"

Xrm.Page.getControl ("St_portfoliomanager"). setvisible (True); Unhide (display) A field named "St_portfoliomanager"

Xrm.Page.getControl ("ownerID"). Setdisabled (True); field with lock field named "ownerID" ( Note: header field plus header_)

Xrm.Page.getControl ("ownerID"). Setdisabled (false); Unlock field with field named "ownerID"

Tabvisible ("Tab_3", false); Hide section named Tab_3 (Note: The parameter is true is displayed)

Displayall (); Hide All tab sections

Xrm.Page.data.save (). Then (function () {parent.window.location.reload ();}); Page Save and Refresh

Xrm.Page.getControl ("St_customerneed"). Refresh (); Local Refresh (sub-grid can also be partially refreshed)

Xrm.Page.ui.getFormType ();//Gets the status of the current page (Note: 1 is new, 2 is modified)

Xrm.Page.ui.close (); Close the current page

Xrm.Page.getControl ("field name"). Removeoption ("value"); Delete options in an option set

assigning values to lookup fields (boarder)
var inputer = new Array ();
var keyer= new Object ();
Keyer.id = Xrm.Page.context.getUserId ();
Keyer.entitytype = "systemuser";
Keyer.name = Xrm.Page.context.getUserName ();
Inputer[0]=keyer;
Xrm.Page.getAttribute ("boarder"). SetValue (Inputer);

new jump to other entities and assign values
var customer= {};
customer["St_accountid"] = Xrm.Page.data.entity.getId (); Assigning a value to the "St_accountid" field of a new entity
customer["St_accountcount"] = 0;
Open a created record
Xrm.Utility.openEntityForm ("New entity name", NULL, customer);

block Save ( Note: Add Xrm.Page.context when calling methods on the page)
function onload () {
var Eventargs=context.geteventargs ();
Eventargs.preventdefault ();

}

path modification for IFRAME or web window
function Product_change () {
var web = Xrm.Page.ui.controls.get ("iframe or Web Form name");
var productid=xrm.page.getattribute ("St_productid"). GetValue ();
if (productid!=null) {

Data is the parameter to be passed
var params = "? Data= "+productid[0].id.replace (' {', ') '. Replace ('} ', ');
var newtarget = Web +params;

Pass Value
WEB.SETSRC (Newtarget);
}
}

Common JS for Dynamics Crm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.