在Dynamics中查找项目选择

时间:2013-05-17 13:21:23

标签: javascript dynamics-crm-2011 lookup microsoft-dynamics

我在Dynamics 2011表单上有自定义查找。我还有一个javascript库来做各种基本验证。我的问题是,如何使用javascript指向查找中的值?以下javascript不起作用...也请看图片。

任何帮助表示赞赏!

http://i.imgur.com/d8vN0H5.png查找

if (Xrm.Page.getAttribute("new_contactmethod").getValue() == Jog) 
{

Xrm.Page.ui.tabs.get("WorkoutDetails").sections.get("Section_Workout").setVisible(true);
  }
else
{
Xrm.Page.ui.tabs.get("WorkoutDetails").sections.get("Section_Workout").setVisible(false);
Xrm.Page.getAttribute("new_distance").setValue(null);

1 个答案:

答案 0 :(得分:1)

您可以通过以下方式检索查找名称:

var methodValue = Xrm.Page.getAttribute("new_contactmethod").getValue();
// we check if the lookup is not empty
if (methodValue != null) {
    var methodName = methodValue[0].name;
    if (methodName == "Jog") {
        // your code here
    }
    else {
        // your code here
    }
}