Skip to main content
Participating Frequently
July 31, 2019
Question

msig_lock is null

  • July 31, 2019
  • 2 replies
  • 686 views

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?

This topic has been closed for replies.

2 replies

Legend
July 31, 2019

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...

Participant
January 16, 2020

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?

Bernd Alheit
Community Expert
Community Expert
January 16, 2020

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

Legend
July 31, 2019

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

Jeff1776Author
Participating Frequently
July 31, 2019

It is a signature field.

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