私は何年もの間問題を解決しようとしてきましたが、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");
}
}
}
}