gpt4 book ai didi

javascript - 如何更改父表单查找值

转载 作者:行者123 更新时间:2023-12-02 18:47:38 25 4
gpt4 key购买 nike

当我从现有机会中打开潜在客户,然后只需更改名字或姓氏的值时,该更改也会反射(reflect)在机会实体中的潜在客户查找中,因此我在联系人实体的 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("名字").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);
}
}

关于javascript - 如何更改父表单查找值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16193602/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com