Copy link to clipboard
Copied
I managed to flatten a form (javascript) with a Submit button. The submit button contains both javascript for flattening and submitting form via email.
This form needs to be locked when submitted by the employees but there are partially section meant for HR use. This HR use must not be flattened and HR should be able to fill this part.
Hence, how do I do this?
Note: Employees most likely to use Adobe reader
Copy link to clipboard
Copied
You can use this script to do it:
var fields = ["Field1", "Field2", "Field3"]; // replace with actual field names
for (var i in fields) {
var f = this.getField(fields);
if (f==null) {
console.println("ERROR! Can't find: " + fields);
continue;
}
f.readonly = true;
}
Copy link to clipboard
Copied
If any users will not be using Acrobat and instead be using Reader, then flattening won't be an option. The closest you can come with Reader is to set certain fields to read-only or lock the entire form by digitally signing. E-signing with Adobe Sign will flatten the entire document, so you can't use it to exclude certain fields when flattening.
Copy link to clipboard
Copied
I'm sorry I don't really understand. So I can't lock some fields and left others fillable by HR is it?
Copy link to clipboard
Copied
You can set them as read-only. It's not exactly "locking"...
Copy link to clipboard
Copied
Understood. So how do I make them partially read-only when viewed by HR? And HR also get to fill the fields meant for them?
Copy link to clipboard
Copied
You can use this script to do it:
var fields = ["Field1", "Field2", "Field3"]; // replace with actual field names
for (var i in fields) {
var f = this.getField(fields);
if (f==null) {
console.println("ERROR! Can't find: " + fields);
continue;
}
f.readonly = true;
}
Copy link to clipboard
Copied
Hi!
I know this post is old but I am in the same situation, trying out the script but it doesn't work!
when I add
var fields = ["Field1", "Field2", "Field3"]; I used my field names, it doesn't work!
If I try it without the [] and just one field, it works. How come it doesnt work with multiple fields?
Thanks!
Copy link to clipboard
Copied
You can use this:
var fields = ["Field1", "Field2", "Field3"]; // replace with actual field names
for (var i in fields) {
var f = this.getField(fields[i]);
if (f==null) {
console.println("ERROR! Can't find: " + fields[i]);
continue;
}
f.readonly = true;
}
Copy link to clipboard
Copied
Thanks Bernd. Just realized that my problem was the super quotes!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now