Rinu
September 12, 2022, 12:42pm
1
Hello,
I am trying to change the status field to 'Review Complete' with the below code.
fd.spBeforeSave(function() {
alert (fd.field('Status').value);
if (fd.field('Status').value == 'Pending Reviewer Approval') {
fd.field('Status').value = 'Review Complete';
alert (fd.field('Status').value);
return fd.save();
}
});
The alert shows the status is changed but the sharepoint list its still shows 'Pending Reviewer Approval'
Dear @Rinu ,
Try it without the return statement, also check that the form actually saves and doesn't get an error while saving.
Rinu
September 12, 2022, 1:05pm
3
Hi Nikita,
I have tried it without return it didnt work, the form saves changes to other field but not the status. I have tried to saving on buttion click, but still didnt work.
window.execButtonAction = function() {
alert (fd.field('Status').value );
if (fd.field('Status').value == 'Pending Reviewer Approval') {
fd.field('Status').value = 'Review Complete';
alert (fd.field('Status').value );
return fd.save();
}
}
The alerts shows the correct values but not saving in the list, I have tried it with out return as well.
Rinu
September 12, 2022, 7:37pm
4
window.execButtonAction = function() {
alert (fd.field('Status').value );
if (fd.field('Status').value == 'Pending Reviewer Approval') {
fd.field('Status').value = 'Review Complete';
fd.field('_x0033_rdGoalReviewerComments').value = 'Review Complete';
alert (fd.field('Status').value );
fd.save();
}
}
Also there where no errors
Dear @Rinu ,
Okay, one thing you can try is to trigger save only after change, like this:
fd.spBeforeSave(function() {
alert (fd.field('Status').value);
if (fd.field('Status').value == 'Pending Reviewer Approval') {
fd.field('Status').value = 'Review Complete';
alert (fd.field('Status').value);
fd.field('Status').$on('change', function() {
fd.save();
});
}
});