1
一個選項集使用正確的選項集定義類別。然後第二個字段只顯示相關的選項。不過,當我逐步瀏覽時,我一直在循環。我做了一個所有正確的值的數組,並調用它們,但我不斷收到一個錯誤:如何根據其他選項集隱藏/顯示選項集CRM Dynamics
TypeError: Cannot read property 'toString' of undefined at Mscrm.TurboForm.Control.View.PicklistEditElement.addOption (https://ugcrmdev.crm9.dynamics.com/_static/form/formcontrols.js?ver=1659449427:24513:38)"
我不知道我在做什麼錯。
var generalServiceRequest = [100000000,100000001,100000002,100000003,100000004,100000005,100000006,100000007,100000008,100000009,100000010,100000011,100000012,100000013,100000014,100000015,100000016,100000017,100000018,100000019,100000020,100000021,100000022,100000023,100000024,100000025,100000026,100000027,100000028,100000029,100000030,100000031,100000032,100000033,100000034,100000035,100000036,100000037,100000038];
var parksAndRec = [100000039,100000040,100000041,100000042,100000043,100000044,100000045];
var boardOfPublicUtilities = [100000046,100000047,100000048,100000049,100000050,100000051];
var publicWorks = [100000052,100000053,100000054,100000055,100000056,100000057,100000058,100000059,100000060,100000061,100000062,100000063,100000064,100000065,100000066,100000067,100000068,100000069,100000070,100000071,100000072,100000073,];
var treasurer = [100000074,100000075,100000076,100000077,100000078,];
var municipalCourt = [100000079,100000080,100000081,100000082,100000083,100000084,100000085,100000086,100000087,];
var districtCourt = [100000088,100000089,100000090,100000091,100000092,100000093,100000094,100000095,];
var neighborHoodResource = [100000096,100000097,100000098,100000099,100000100,100000101,100000102,100000103,100000104,100000105,];
var sheriff = [100000106,100000107,100000108,100000109,100000110,];
//OnLoad of form and OnChange of Specify field.
function masterOptionSet() {
resetOptionSet();
var optionValue = Xrm.Page.getAttribute("new_specifyservicerequest").getValue();
switch (optionValue) {
case 100000000:
showOptionSet(generalServiceRequest);
break;
case 100000001:
showOptionSet(parksAndRec);
break;
case 100000002:
showOptionSet(boardOfPublicUtilities);
break;
case 100000003:
showOptionSet(publicWorks);
break;
case 100000004:
showOptionSet(treasurer);
break;
case 100000005:
showOptionSet(municipalCourt);
break;
case 100000006:
showOptionSet(districtCourt);
break;
case 100000007:
showOptionSet(neighborHoodResource);
break;
case 100000008:
showOptionSet(sheriff);
}
}
function resetOptionSet()
{
for(var i = 100000000; i <= 100000110; i++){
Xrm.Page.getControl("new_subjectmatter").removeOption(i);
}
}
function showOptionSet(optionArray){
for(var i = 0; i< optionArray.length; i++){
Xrm.Page.getControl("new_subjectmatter").addOption(optionArray[i]);
}
}
下面的答案應該讓你擺脫依賴的選擇列表。由於看起來您正在構建某種縣服務或311系統,爲了避免在更改時維護這些編碼依賴關係的長期開銷,您可能還需要考慮使用具有過濾查找的實體。 – Aron
我同意阿倫在查找解決方案。順便說一句,可配置的依賴選擇列表可能使用一些社區代碼。我已經用那個鏈接更新了答案。 –