我一直在努力解决一个问题,但我不知道JavaScript,所以我在互联网上追逐我的尾巴。客户关系管理2011家长活动实体
我已经继承了一个JavaScript文件,当在一个帐户上制定一个计划时应该触发一个JavaScript文件。每个帐户可以有多个计划,但一次只能有1个活动计划。这意味着当你创建一个新的时候,你应该只能在所有其他人都被禁用的情况下才能使用。我们现在的代码(见下文)只会查找计划的存在,而不管其状态如何。谁能帮我吗?
由于
checkActiveADP = function()
{
// check if there is a key account populated
if (Xrm.Page.getAttribute("new_keyaccountid").getValue() != null && Xrm.Page.ui.getFormType() == 1)
{
// get the id of the parent account of the account plan
var keyaccountid = Xrm.Page.getAttribute("new_keyaccountid").getValue()[0].id;
if (keyaccountid != null)
{
// build query to get all the account plans for the current parent account - if any
var filter = "/New_accountplanSet()?$filter=new_keyaccountid/Id eq guid'" + keyaccountid + "'";
var retrievedMultiple = CCrm.JSCore.RetrieveMultipleRequest(filter);
if (retrievedMultiple.results.length >=1)
{
alert("Active ADP already exists, please update that one or deactivate before creating a new one");
}
}
}
}
你会得到任何结果吗?尝试'alert(retrieveMultiple.results.length);' – Scorpion
当它运行,并有停用计划链接到父帐户它引发消息,并不会让你保存一个新的。 – Powell21