Hello,
Although I am using SharePoint Online Forms, I am trying to configure a task list which is in classic mode. I am trying to change all fields to read only for one particular form based on sharepoint group. Code seems to work when I change to 100% however if I change back to 50% and save it changes back to 100%. I am not sure what I am doing wrong. Goal is to have all fields set to read only when percentage is 100% . Want to do based on Percent complete not status. My code is pasted in javascript above.
function setPercentComplete() {
if (fd.field('PercentComplete').value('100')) {
// Setting the Percent Complete to 100
fd.field('Status').value() == 'Completed'
// Getting JQuery-object of the field and disable it
fd.field('Title').readonly(true);
} else {
// Getting JQuery-object of the field and enable it
fd.field('Title').readonly(false);
}
}
// Calling setPercentComplete when the user changes the status
fd.field('PercentComplete').change(setPercentComplete);
// Calling setPercentComplete on form loading
setPercentComplete();
// Enabling fields before the submission
fd.onsubmit(function () {
fd.field('Title').readonly(false);
return true;
});
To check the PercentComplete field value you need to use this code:
if(fd.field('PercentComplete').value() == 100){
}
And to change the field value use this code:
fd.field('Status').value('Completed')
Thus, this code should work for you:
function setPercentComplete() {
if (fd.field('PercentComplete').value() == 100) {
// Setting the Percent Complete to 100
fd.field('Status').value( 'Completed');
// Getting JQuery-object of the field and disable it
fd.field('Title').readonly(true);
} else {
// Getting JQuery-object of the field and enable it
fd.field('Title').readonly(false);
}
}
// Calling setPercentComplete when the user changes the status
fd.field('PercentComplete').change(setPercentComplete);
// Calling setPercentComplete on form loading
setPercentComplete();
// Enabling fields before the submission
fd.onsubmit(function () {
fd.field('Title').readonly(false);
return true;
});
You can find more details on how to manage field with JavaScript in Forms Designer here:
Just for the future, questions regarding Forms Designer and Cross-Site Lookup are better answered in the official Forms Designer forum here: Forms Designer Forum - Index page