Getting can not read property 'length' of undefined error

Hi Team,

I am using set and get methods in property panel for input fields.Please find the piece of code.

var ruleSetEntry = entryFactory.textField({
		    id: 'ruleSetId',
		    description: '',
		    label: 'RuleSetId',
		    modelProperty: 'ruleSetId',
		    set : function(element, values) {
			   var businessObject = getBusinessObject(element),
			       newObjectList = [];
			
			   if (typeof values.ruleSet !== 'undefined' && values.ruleSet !== '') {
			     newObjectList.push(bpmnFactory.create('bpmn:RuleSetId', {
			       text: values.ruleSet
			     }));
			   }
			   return cmdHelper.setList(element, businessObject, 'ruleSetId', newObjectList);
			 },
			
			 get : function(element) {
			   var businessObject = getBusinessObject(element);
			   var documentations = businessObject.get('ruleSetId'), text = (documentations.length > 0) ? documentations[0].text : '';
			      return { ruleSetId: text };
			 }
		     });
	 group.entries.push(ruleSetEntry);

with this code i am getting ‘can not read property ‘length’ of undefined’.Please find the attached screenshot.Please let me know why this error coming in console.

Thanks
-Prameela

Hi,

Did you try to debug it?

By the look of it documentations is used before actually being set.
…Or businessObject.get('ruleSetId') returns an undefined result.

Cheers,
Vladimir

Hi vladimirs,

Before set method i tried calling get method,still same error and businessObject.get(‘ruleSetId’) returning an undefined result.

Thanks
-Prameela

I would advice to write some test cases that cover what you are trying to achieve and try to debug your code.

Please, see example as a reference and look for hints in source repository for the properties panel on how to achieve your requirement.

Cheers,
Vladimir