Hello All, 

We noticed a bug in the add-on MultiChoice. The process to replicate the issue is the following:

  1. Configure two MultiChoice fields on a page.
  2. Edit one of the MultiChoice fields, but not both.
  3. Save the record
  4. After the record is saved, the MultiChoice field that was not edited now has the values cleared out.

We found that if you refresh the page, the values appear again. Has anyone else experienced this issue? Or has anyone found a workaround to prevent the field from clearing out on save?

 

Thank you!

Chris

Like 0

Like

2 comments

Hi Chris,

I've experienced this same issue. There's problems if you have two of these on the same page - I started looking into workarounds, but ended up switching to just standard details and made them look more similar to the MultiChoice layout (see https://customerfx.com/article/changing-a-detail-grid-to-a-horizontal-l…) instead so never found a resolution. 

Just wanted to mention so you know it's not just you or something you did. Wish I had a workaround to provide :( 

Ryan

I found resolution, file: MultiChoiceMixin, method: loadMultiChoiceColumns, replace row

viewModel.set(columnName, rowsItems);

with 

viewModel.trigger("change:" + columnName, rowsItems);

Idk how it works but it helps

Show all comments

Hi community,

 

I installed the multichoice package from the marketplace and I created a combobox but for some reason I'm not able to save the data once I filled the created combobox.

 

Here is my schema :

define("MTF_Candidat1Page", ["MultiChoiceMixin"], function() {
	return {
		entitySchemaName: "MTF_Candidat",
		attributes: {
			"UsrComboBox": {
				"dataValueType": Terrasoft.DataValueType.LOOKUP
			},
		},
		mixins: {
			MultiChoiceMixin: "Terrasoft.MultiChoiceMixin"
		},
		methods: {
			init: function() {
				this.callParent(arguments);
				this.mixins.MultiChoiceMixin.init.call(this, arguments);
			},
			getMultiChoiceEntitiesConfig: function() {
				items = {
					UsrComboBox: {
						mainEntitySchemaName: "MTF_Candidat",
						mainColumnName: "Lkp_Francais",
						relatedEntitySchemaName: "MTFcompetenceslinguistiques",
						relatedColumnName: "Name"
					}
				};
				return items;
			}
		},
		...
		diff: /**SCHEMA_DIFF*/[
		...
		{
				"operation": "insert",
				"parentName": "TabMTFInfosCandidatTabLabelGridLayoutd7450211",
				"propertyName": "items",
				"name": "UsrComboBox",
				"values": {
					"className": "Terrasoft.MultiChoiceCombobox",
					"layout": {
						"colSpan": 12,
						"rowSpan": 2,
						"column": 0,
						"row": 0,
						"layoutName": "TabMTFInfosCandidatTabLabelGridLayoutd7450211"
					},
					"bindTo": "UsrComboBox",
					"dataValueType": Terrasoft.DataValueType.ENUM,
					"labelConfig": {
						"caption": "Test ComboBox"
					}
				},
 
			},
		...
		]/**SCHEMA_DIFF*/
	};
});

"UsrComboBox" is an attribute I created in the attributes of this schema.

"MTF_Candidat" is an object that I created in the page wizard.

"Lkp_Francais" is the field ID for a lookup already defined in the page wizard. By default when I created Lkp_Francais, the connected lookup is "MTFcompetenceslinguistiques".

"MTFcompetenceslinguistiques" is a basic lookup with only the inherited fields

 

It produces this combobox :

The UI part it works fine :

But if I save my object, close it and reopen it, the data previously filled in the combobox are no longer there:

 

I tried to generate the source code for all the modified schemas in the advanced settings, then I recompiled everything and it still doesn't work.



Do you have any idea what is going on and what I can do to solve this problem?

 

EDIT : in my getMultiChoiceEntitiesConfig method I tried to change

mainColumnName: "Lkp_Francais"

to

mainColumnName: "Id"

as recommanded in https://marketplace.creatio.com/app/multiple-choice-field-setup-creatio under the installation part and this time when I save my object it just load indefinitely. I tried to change it to "MTFContactCandidat" which is a lookup connected to a Contact object and the result was the same,when I click on save it loads indefinitely.

 

Best regards,

 

Julien G.

Like 0

Like

2 comments
Best reply

Hi Julien,

This add on should work with a detail which linked with your main entity (MTF_Candidat) and the lookup (MTFcompetenceslinguistiques).

 

According to the information you mentioned, you only have a field in the MTF_Candidat which linked to MTFcompetenceslinguistiques.



Therefore, you need change your design by creating a detail which allows you to store multiple records from the lookup and link to the main object.

 

After that your item configuration should be something like this:

 

items = {
 UsrComboBox: {
		mainEntitySchemaName: "DetailObject", //Detail Object code
		mainColumnName: "ColumnConnectedToMainObject", //The column in the created detail which link to MTF_Candidat.
		relatedEntitySchemaName: "MTFcompetenceslinguistiques", //Lookup object,Your configuration is Correct.
		relatedColumnName: "ColumnConnectedToLookup" //The column in the created detail which link to MTFcompetenceslinguistiques
	}
};

regards,

 

Cheng Gong

Hi Julien,

This add on should work with a detail which linked with your main entity (MTF_Candidat) and the lookup (MTFcompetenceslinguistiques).

 

According to the information you mentioned, you only have a field in the MTF_Candidat which linked to MTFcompetenceslinguistiques.



Therefore, you need change your design by creating a detail which allows you to store multiple records from the lookup and link to the main object.

 

After that your item configuration should be something like this:

 

items = {
 UsrComboBox: {
		mainEntitySchemaName: "DetailObject", //Detail Object code
		mainColumnName: "ColumnConnectedToMainObject", //The column in the created detail which link to MTF_Candidat.
		relatedEntitySchemaName: "MTFcompetenceslinguistiques", //Lookup object,Your configuration is Correct.
		relatedColumnName: "ColumnConnectedToLookup" //The column in the created detail which link to MTFcompetenceslinguistiques
	}
};

regards,

 

Cheng Gong

Cheng Gong,

 

Thanks for your answer!

 

 

Show all comments

Hi All, 

 

We noticed a bug in the add-on MultiChoice. The process to replicated the issue is following:

Bug-1:

  1. Configure one multi-choice combobox on any page.
  2. Select 2 values from the list and save it. 

    So far, in the database there are only two entries in the detail as you are expected.
  3. Do not close the page and add extra 4 lookup from the list and save it.

    Now, in the database there are 8 records in the detail instead of 6. The first 2 lookup I selected were duplicated.
  4. After that the Combobox does not work anymore. no matter what you do (delete, select new entry) will not be saved anymore.

Bug-2:

  1. Configure the lookup value from the above example. Ensure you have tow lookup with the same value your lookup table.
  2. On the page, select the two values which are duplicated in the list.
  3. Do not close the page, and remove 1 value from the list and save the page.
  4. You will see the value is removed from UI. But it is still in the database. If you reload the page, the remove record will show again on the UI.
  5. Reload the page, and remove 1 value. This time you will see it has been removed.

For the bug-1, I use a business process to double check if there a duplicates. It is not the best solution, but it works.

 

Is there anyone who has the same experience?

 

best regards,

 

Cheng Gon

Like 1

Like

3 comments
Best reply

I do get the same issue, I just had not noticed this behavior until I read your post and tested it. The issue is that the code expects that onSaved (after the save) you've left the page and all gets destroyed instead of modifying the collections used with the updated/deleted items.

As a temporary solution/fix, you can add this to the page where the MultiChoice component is used: 

updateMultiChoiceRecords: function() {
	if (!this.$IsNeedToUpdateMultiChoice) {
		return;
	}
	const items = this.getMultiChoiceEntitiesConfig();
	const batch = this.Ext.create("Terrasoft.BatchQuery");
	this.Terrasoft.each(items, function(config, columnName) {
		this.addDeleteQuery(config, columnName, batch);
		this.addInsertQuery(config, columnName, batch);
	}, this);
	this.$IsNeedToUpdateMultiChoice = false;
	batch.execute(function() {
		this.loadMultiChoiceColumns(this);
	}, this);
}

Really, all we need is to be able to execute the loadMultiChoiceColumns function in the callback from the batch execute, however, there's no other way to do it other than replace the entire updateMultiChoiceRecords function from the MultiChoiceMixin. You'll get a quick flicker on save since this recreates the collections of items initially bound to the control  - ideally you'd just read the response from the batch and just add the inserted objects and remove the deleted only. But for now it will at least fix the behavior. I didn't do that in the above since it's easier to just reload the collections - hopefully the devlabs team will see this and release a proper fix.

Ryan

I do get the same issue, I just had not noticed this behavior until I read your post and tested it. The issue is that the code expects that onSaved (after the save) you've left the page and all gets destroyed instead of modifying the collections used with the updated/deleted items.

As a temporary solution/fix, you can add this to the page where the MultiChoice component is used: 

updateMultiChoiceRecords: function() {
	if (!this.$IsNeedToUpdateMultiChoice) {
		return;
	}
	const items = this.getMultiChoiceEntitiesConfig();
	const batch = this.Ext.create("Terrasoft.BatchQuery");
	this.Terrasoft.each(items, function(config, columnName) {
		this.addDeleteQuery(config, columnName, batch);
		this.addInsertQuery(config, columnName, batch);
	}, this);
	this.$IsNeedToUpdateMultiChoice = false;
	batch.execute(function() {
		this.loadMultiChoiceColumns(this);
	}, this);
}

Really, all we need is to be able to execute the loadMultiChoiceColumns function in the callback from the batch execute, however, there's no other way to do it other than replace the entire updateMultiChoiceRecords function from the MultiChoiceMixin. You'll get a quick flicker on save since this recreates the collections of items initially bound to the control  - ideally you'd just read the response from the batch and just add the inserted objects and remove the deleted only. But for now it will at least fix the behavior. I didn't do that in the above since it's easier to just reload the collections - hopefully the devlabs team will see this and release a proper fix.

Ryan

Ryan Farley,

Thanks for the solution here. Just implemented your suggestion and it works perfectly.  Both of 2 bugs has been solved once we reload the collections after saving.

Ryan Farley,

 

Hello Ryan!



Thank you for your solution. We tested it on our end and implemented it in the add-on.

Show all comments