0
我有一條記錄,表示停用時我希望插件自動刪除記錄。因此,我將我的代碼設置爲SetStateDynamically事件,並且它一直運行到我實際獲得服務來刪除該記錄的位置,在那裏出現「發生意外錯誤」。嘗試在關閉時刪除記錄時出錯
我的代碼在下面,任何人都可以看到問題可能是什麼,或者能夠指向正確的方向嗎?
感謝
private void MarkForDeleteDeactivatedRole(EntityReference entity)
{
Entity role = Service.Retrieve("sb_contactsecurityrole", entity.Id, new ColumnSet(true));
OptionSetValue statusValue = (OptionSetValue)role["statecode"];
if (statusValue.Value == 1)
{
Service.Delete(entity.LogicalName, entity.Id);
}
}
什麼是實際錯誤?如果您檢查日誌或附加調試器,您將成爲更具體的消息。另外你的插件如何註冊(前/後等)? –
您應該提供完整的Execute()方法以開始。另外,嘗試將第二個方法行更改爲'... =(OptionSetValue)role.Attributes [「statecode」];' – Alex
您是否試圖通過Workflow進行操作? – Grigory