我如何更改父表单查找值



当我从现有的机会中打开潜在客户,然后只是更改名字或姓氏的值,然后更改也反映在机会实体中的潜在客户查找中,所以我在联系人实体的onsave中编写了一个脚本。

function getname()
{
    var lookupValue = new Array();
    lookupValue[0] = new Object();
    lookupValue[0].id = Xrm.Page.data.entity.getId();
    lookupValue[0].name = Xrm.Page.data.entity.attributes.get("firstname").getValue()+" " +Xrm.Page.data.entity.attributes.get("lastname").getValue();
    alert(Xrm.Page.data.entity.attributes.get("firstname").getValue()+" " +Xrm.Page.data.entity.attributes.get("lastname").getValue());
    lookupValue[0].entityType = "Contact";
    window.top.opener.Xrm.Page.data.entity.attributes.get("customerid").setValue(lookupValue);
            window.top.opener.Xrm.Page.data.entity.attributes.get("name").setValue(Xrm.Page.data.entity.attributes.get("firstname").getValue());
}

如果你看看上面的代码,那么你会发现我已经设置了父查找的值,但它没有工作。我已经改变了文本框主题(名称)的机会的值,所以它将为我工作,但我不知道为什么它没有在查找工作。

如果你看我上面的代码,你会发现一行window.top.opener.Xrm.Page.data.entity.attributes.get("name").setValue(Xrm.Page.data.entity.attributes.get("firstname").getValue());这个可以很好地工作但是在查找

中不起作用

序言:不支持这种代码。

如果你想让它工作,你只需要改变name属性,因为identityType不会改变(至少与你描述的行为)

如果在开头符中有字段,最好也加一个检查:

function getname()
{
if (window.top.opener.Xrm.Page.getAttribute("customerid") != null)
{
    var previous = window.top.opener.Xrm.Page.getAttribute("customerid").getValue();
    previous[0].name = Xrm.Page.getAttribute("firstname").getValue() + " " + Xrm.Page.getAttribute("lastname").getValue();
    window.top.opener.Xrm.Page.getAttribute("customerid").setValue(previous);
}
}

查找对象将始终显示相关实体的主属性。这是无法改变的。所以我并不惊讶,试图设置这个值不起作用。永远不会。

你想达到什么目标?为什么要将查找中的显示更改为不表示它所链接的记录呢?

最新更新