msig_lock is null

New Here ,
Jul 31, 2019

Copy link to clipboard

Copied

I am getting msig_lock is null error when I do the following:

var m = this.getField('dt2_member_sig_'+n);

    var msig_lock = m.getLock();

    msig_lock.action = 'Include';

    msig_lock.fields = mfields;

Anyone have any ideas?

TOPICS
Acrobat SDK and JavaScript

Views

97

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

msig_lock is null

New Here ,
Jul 31, 2019

Copy link to clipboard

Copied

I am getting msig_lock is null error when I do the following:

var m = this.getField('dt2_member_sig_'+n);

    var msig_lock = m.getLock();

    msig_lock.action = 'Include';

    msig_lock.fields = mfields;

Anyone have any ideas?

TOPICS
Acrobat SDK and JavaScript

Views

98

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 31, 2019 0
Most Valuable Participant ,
Jul 31, 2019

Copy link to clipboard

Copied

Suggest checking m.type (perhaps writing to the console) before continuing with the getLock.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2019 0
New Here ,
Jul 31, 2019

Copy link to clipboard

Copied

It is a signature field.

this.addField('dt2_member_sig_'+n, 'signature', this.pageNum, [30.37, 117.44, 441.07, 97.28])

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2019 0
Most Valuable Participant ,
Jul 31, 2019

Copy link to clipboard

Copied

Still, since we have no other ideas, I suggest putting the validation in. Who knows what could have happened, or what bugs it may uncover...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2019 0
New Here ,
Jan 16, 2020

Copy link to clipboard

Copied

below is my code for creating a form based on a condition:

			var sShield = this.getField(nShield).value;
			this.getTemplate('PostDiveReport').spawn(this.numPages, false, false);
			this.pageNum = this.numPages-1;
			var pageFields = [
				{field:this.addField('Detail'+nDiverNum, 'text', this.pageNum, [387.36, 748.08, 468.55, 728.66]), value:'', property:'center'},
				{field:this.addField('Troop'+nDiverNum, 'text', this.pageNum, [501.09, 747.98, 581.46, 728.66]), value:'', property:'center'},
				{field:this.addField('SJS'+nDiverNum, 'text', this.pageNum, [387.48, 727.83, 468.51, 707.55]), value:'', property:'center'},
				{field:this.addField('Date'+nDiverNum, 'text', this.pageNum, [501.17, 727.83, 581.82, 707.55]), value:'', property:'center'},
				{field:this.addField('Shield'+nDiverNum, 'text', this.pageNum, [505.31, 699.32, 582, 685.7]), value:'shield', property:'center'},
				{field:this.addField('PostDiveReviewNarrative'+nDiverNum, 'text', this.pageNum, [30.48, 669.71, 581.04, 84.33]), value:'', property:'comment'},
				{field:this.addField('PostDiveSeniorDiverSignature'+nDiverNum, 'signature', this.pageNum, [30.48, 53.18, 305.35, 33.02]), value:'', property:'sig1'},
				{field:this.addField('PostDiveDivisionDivingOfficerSignature'+nDiverNum, 'signature', this.pageNum, [306.76, 53.61, 581.56, 33.45]), value:'', property:''}
			];
			pageFields.forEach(function (ai) {
				ai.field.textFont = font.HelvB;
				ai.field.textSize = 0;
				if (ai.property === 'center') {
					ai.field.alignment = 'center';
				}
				if (ai.property === 'comment') {
					ai.field.multiline = true;
					ai.field.doNotScroll = true;
				}
				if (ai.value === 'shield') {
					ai.field.value = sShield;
				}
				if (ai.property === 'sig1') {
					var f = this.getField('PostDiveSeniorDiverSignature'+nDiverNum);
					var oLock = f.getLock();
					oLock.action = 'Include';
					oLock.fields = ['Detail'+nDiverNum, 'Troop'+nDiverNum, 'SJS'+nDiverNum, 'Date'+nDiverNum, 'Shield'+nDiverNum, 'PostDiveReviewNarrative'+nDiverNum, 'PostDiveSeniorDiverSignature'+nDiverNum];
					f.setLock(oLock);
				}
			});

 var oLock = f.getLock(); seems to always return null?

 

actual returned erroro: TypeError: oLock is null
37:Document-Level:main

Line 37 is actually the var oLock line?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 16, 2020 0
Adobe Community Professional ,
Jan 16, 2020

Copy link to clipboard

Copied

May be that the locks of the field are not set.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 16, 2020 0
New Here ,
Jan 16, 2020

Copy link to clipboard

Copied

That is exactly what I am attempting to do.  Grab the field object then grab the lock obj from the field object.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 16, 2020 0
Adobe Community Professional ,
Jan 16, 2020

Copy link to clipboard

Copied

Does you get the object when you change the field properties in Acrobat?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 16, 2020 0
New Here ,
Jan 16, 2020

Copy link to clipboard

Copied

I am creating a new page with a new signature field and inserting it into my pdf.  when i completed creating the base sig field on the new page, I then attempt to grab the lock object from the sig field to update its properties.  When attempting to grab the lock obj it returns null has if it can not get it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 16, 2020 0
Adobe Community Professional ,
Jan 16, 2020

Copy link to clipboard

Copied

Have you changed the property in Acrobat under Prepare Form?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 16, 2020 0
New Here ,
Jan 16, 2020

Copy link to clipboard

Copied

It lets me manually add the lock conditions without error.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 16, 2020 0
Adobe Community Professional ,
Jan 17, 2020

Copy link to clipboard

Copied

You must enable the option "Mark as read-only":

Bild1.jpg

Then you will get a value for getLock().

 

You can set the locks direct, like this:

f.setLock({action:"Include", fields:["Text1", "Text2"]});

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 17, 2020 0