Hello,
I have a list or library to upload files. On upload, a popup (Dialog) box is shown to update metadata.
The scenario is that on update, I save the form to be able to update the status. After that the metadata dialog is opened.
Problem here is: I have added a validator to check the length of the uploaded file. but this does not work with the normal fd.save().
What I want to achieve is to first check the length of file, if it is not valid, then show the error without opening the dialog.
This is what i have so far:
fd.control('InitialFilesTable').$on('change', function (changeData) {
if (changeData.type === 'upload') {
dstat = 'Initial';
$('.submittedGrid').show();
addReviewSharingButton('InitialFilesTable', 'b72cef8a-f671-45e2-ba9d-d288c6ab6881');
if (fd.field('Initial_Reset').value) fd.field('Initial_DMPUploaded').value = true;
else if (fd.field('InitialStatusDmpReview').value === 'Reviewed, new upload needed') {
fd.field('Initial_DMPUploaded').value = true;
$('#initialTableMsg').html('New DMP uploaded... <b>Please wait for new review.</b>');
}
$('#DStatus').html(dstat);
}
if (changeData.type === 'delete') {
dstat = 'No DMP';
$('.submittedGrid').hide();
$('.btn-info').hide();
$('#DStatus').html(dstat);
}
fd.field('Status').value = dstat;
fd.save();
fd._showAlert = function () { };
});
function validateFilesUpload() {
fd.validators.push({
name: 'DMP upload validator',
error: 'Error Message',
validate: function () {
var initTable = fd.control('InitialFilesTable').widget.dataItems();
if (initTable.length === 1) {
var initialFilename = initTable[0].FileRef;
if (initialFilename.length > 155) {
this.error = 'Please shorten your initial filename. Maximum allowed characters is 155.'
return false;
}
}
}
});
}
function OpenMetadata() {
fd.control('InitialFilesTable').ready().then(function (dt) {
fd.control('InitialFilesTable').$on('filesUploaded', function (itemIds) {
validateFilesUpload();
if (fd.isValid) openDialog('2f8e98a9-991e-4403-b5ea-0abdfe65123e');
});
});
}
Could you please see how to solve this?
Thanks in advance for the help.