Best method of auto filling
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Hello, Roo!
You can try code like this:
Change field names to internal names of your fields and it should work.
You can try code like this:
Code: Select all
fd.field('Checkbox').change(function(){
if(fd.field('Checkbox').value()){
fd.field('By').value(_spPageContextInfo.userLoginName);
fd.field('Date').value(new Date());
}
else{
fd.field('By').value(null);
fd.field('Date').value(null);
}
});
Cheers
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Yeah, exactly, it would be better to do it in the code. Make them readonly when you open the form, then set readonly to false prior to changing values and back to true once new values are set.I guess I could do this in the code?
Something like this should work:
Code: Select all
fd.field('Title').readonly(true);
fd.field('Checkbox').change(function(){
fd.field('Title').readonly(false);
if(fd.field('Checkbox').value()){
fd.field('Title').value('New Title');
}
else{
fd.field('Title').value(null);
}
fd.field('Title').readonly(true);
});
Cheers
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
One last thing, you also need to have all fields set to Readonly:false when you save an item, otherwise these values won't save correctly.
So, add something like this in the end of JavaScript editor:
So, add something like this in the end of JavaScript editor:
Code: Select all
fd.onsubmit(function(){
fd.field('By').readonly(false);
fd.field('Date').readonly(false);
return true;
});
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 4 guests