创建dynamics CRM client-side (二)

如果我们想用script来直接在form上做一些修改, 我们需要用到client api 来做交互.

我们可以用以下来理解:

Form <---> Client API <---> Script

Client API Objects Model

1. Execution Context

  

2. formContext

  formContext是获取form的权限.

  formContext 有两个object. 

    1. Data object (formContext.data.entity.attributes)

      如果需要access textbox当中的data, 我们需要使用data object

function DisplayHelloWorld(executionContext) {
    var formContext = executionContext.getFormContext();

    // var firstName = formContext.data.entity.attributes.get("firstname").getValue();

    // this is shortcut
    var firstName = formContext.getAttribute("firstname").getValue();

    alert("Hello World " + firstName);
}

    2. UI object (formContext.ui.controls)

      Access controls. e.g. disable control, hide control

  如果想获取formContext, 必须使用executionContext来获取formContext

  

var formContext = executionContext.getFormContext();

  

3. gridContext

4. Xrm Object

原文地址:https://www.cnblogs.com/TheMiao/p/10996815.html