MICROSOFT DYNAMICS 365: NOTIFICAções usando JAVASCRIPT
Notificações de nível de formulário (com e sem persistência), notificações de nível de campo e notificações de caixas popup usando JavaScript.
Sumário
- Formulário – Set Notification
formContext.ui.setFormNotification(message, messageType, uniqueId); - Formulário – Clear Notification
formContext.ui.clearFormNotification(uniqueId); - Campo Especifico – Set Notification
formContext.getControl(nomecampo).setNotification(message, uniqueId); - Campo Especifico – Clear Notification
formContext.getControl(nomecampo).clearNotification(uniqueId); - Alert Box
alert(message); - Confirmation Box
confirm(message); - Prompt Box
prompt(message, sampleText);
Notificações no Formulário

Abaixo está o código JavaScript que foi utilizado para gerar as notificações mostradas na imagem acima. Portanto, cada vez que um utilizador abrir um formulário de contacto, estas notificações aparecerão sempre na parte superior do formulário.
function FormLevelNotification(executionContext) {
var formContext = executionContext.getFormContext();
formContext.ui.setFormNotification("Example of an ERROR notification. ", "ERROR");
formContext.ui.setFormNotification("Example of a WARNING notification. ", "WARNING");
formContext.ui.setFormNotification("Example of an INFORMATION notification.", "INFO");
}Notificação especifica de campo

function TvSuscriptionDateValidation(executionContext) {
var formContext = executionContext.getFormContext();
var tvSubStartDateLogicalName = "hos_tvsubstartdate";
var tvSubEndDateLogicalName = "hos_tvsubenddate";
var startDateField = formContext.getAttribute(tvSubStartDateLogicalName);
var endDateField = formContext.getAttribute(tvSubEndDateLogicalName);
var endDateFieldControl = formContext.getControl(tvSubEndDateLogicalName);
var startDate, endDate;
if (startDateField != null && endDateField != null) {
startDate = startDateField.getValue();
endDate = endDateField.getValue();
if (IsDate(startDate) && IsDate(endDate) && startDate > endDate ) {
//Display an error message if the dates entered are logically invalid.
endDateFieldControl.setNotification("The Subscription End Date cannot be before Subscritpion Start Date.", "tvEndDate");
endDateField.setValue(null);
}
else {
endDateFieldControl.clearNotification("tvEndDate");
}
}
}
//Verify that the field contains date instead of a null value
function IsDate (input) {
if (Object.prototype.toString.call(input) === "[object Date]") {
return true;
}
return false;
}Popup Notificações
Mensagem de alert

function AlertBox() {
alert("This is an example of a JavScript Alert window ");
//Alternatively way of writing an Alert Box with the Window prefix:
//window.alert("This is an example of a JavScript Alert window ");
}Mensagem de Confirmação

function ConfirmBox() {
var confirmationText;
if (confirm("Would you like to proceed?")) {
confirmationText = "You pressed OK!";
} else {
confirmationText = "You pressed Cancel!";
}
//Using the alert notification to show the option selected
alert(confirmationText);
//Alternatively way of writing an Confirm Box with the Window prefix:
//window.confirm("Press a button: 'OK' or 'Cancel'");
}Popup de prompt

function PromptBox() {
var userText = prompt("Please enter your name below", "This is sample text ");
//Using the alert notification to show the text entered in the prompt box
alert("You said your name is: \n" + userText);
//Alternatively way of writing an Prompt Box with the Window prefix:
//window.prompt("Please enter some text below", "This is sample text ");
}
Nenhum comentário:
Postar um comentário