Today i got a requirement where i need to get all fields which have been modified by the user.
Also there is additional requirement to set their submit-mode to Never.
Sharing you XRM Script for the same.
function MakeFieldUnDirty() {
var attributes = Xrm.Page.data.entity.attributes.get();
for (var i in attributes) {
var attribute = attributes[i];
if (attribute.getIsDirty())
attribute.setSubmitMode("never")
}
}
------------------------------------------------
Also there is additional requirement to set their submit-mode to Never.
Sharing you XRM Script for the same.
function MakeFieldUnDirty() {
var attributes = Xrm.Page.data.entity.attributes.get();
for (var i in attributes) {
var attribute = attributes[i];
if (attribute.getIsDirty())
attribute.setSubmitMode("never")
}
}
------------------------------------------------
Making fields read-only is a great way to restrict change or to make sure input is valid. However, all read-only fields are not submitted by default onSave event.
This is not desirable if you are automatically populating fields from user input on another field(s) and those fields cannot be changed by user. Those auto-populated fields will never be saved.
To make sure the fields are saved, we can call javascript function
setSubmitMode
.Xrm.Page.getAttribute(
"<field name>"
).setSubmitMode(
"<submit value>"
);
Submit values available are:
- always
- never
- dirty
No comments:
Post a Comment