2 回答

TA貢獻1772條經驗 獲得超6個贊
考慮到您使用的是 Dynamics 的最新在線版本,我建議您使用帶有執行上下文的用戶添加通知。
這是您需要的代碼,需要根據您的需要進行自定義,示例顯示建議的通知類型,但您可以使用錯誤,這樣表單也不會保存并顯示錯誤。
function addTickerSymbolRecommendation(executionContext) {
var formContext = executionContext.getFormContext();
var myControl = formContext.getControl('name');
var accountName = formContext.data.entity.attributes.get('name');
var tickerSymbol = formContext.data.entity.attributes.get('tickersymbol');
if (accountName.getValue() == 'Microsoft' && tickerSymbol.getValue() != 'MSFT') {
var actionCollection = {
message: 'Set the Ticker Symbol to MSFT?',
actions: null
};
actionCollection.actions = [function () {
tickerSymbol.setValue('MSFT');
myControl.clearNotification('my_unique_id');
}];
myControl.addNotification({
messages: ['Set Ticker Symbol'],
notificationLevel: 'RECOMMENDATION',
uniqueId: 'my_unique_id',
actions: [actionCollection]
});
}
else
console.log("Notification not set");
}
添加回答
舉報