Bulk addition to a detail with filters

Hi all,

 

I have implemented the use of bulk addition to a detail using this Creatio Academy article.



If possible, I would like to filter the bulk addition records to match the business rules of the page i.e. AddressType = 'Site'

				"3361d12a-6dde-417b-b462-d7e171af7edf": {
					"uId": "3361d12a-6dde-417b-b462-d7e171af7edf",
					"enabled": true,
					"removed": false,
					"ruleType": 1,
					"baseAttributePatch": "AddressType",
					"comparisonType": 3,
					"autoClean": false,
					"autocomplete": false,
					"type": 0,
					"value": "7a5d8cdb-54d6-46ce-8b5c-a4a9b319dbb7", //AddressType = 'Site'
					"dataValueType": 10
				}
			}

Is there any way that this can be implemented?

Like 0

Like

3 comments
Best reply

By way of an epilogue and for anyone who happens this way in the future.

 

To filter the lookup add the following method to the detail source code (ref.  Creatio Academy):

//  Filter the lookup entries.
getAdditionalLookupFilters: function() {
	var filterGroup = new this.Terrasoft.createFilterGroup();
	filterGroup.add("ByCaseStatusFilter", this.Terrasoft.createColumnFilterWithParameter(
		this.Terrasoft.ComparisonType.EQUAL, "AddressType", "7a5d8cdb-54d6-46ce-8b5c-a4a9b319dbb7")
	);
	return filterGroup;
}

This overrdes the method in LookupMultiAddMixin.js.

Hello,

 

Business rules cannot be implemented here unfortunately since we need to filter data in the opened modal window to select records. But you can try overriding the logic of the openLookupWithMultiSelect method in your detail schema and add your filters to the config.filters object (you need to debug openLookupWithMultiSelect method execution). For example:

 

1) Register a message in the detail schema with the PUBLISH type.

2) Register an attribute in the detail schema that will store "AddressType" of a main record.

3) In the main page schema register the same message as in step 1, but with the SUBSCRIBE type.

4) Override base subscribeSandboxEvents method in the main record schema and subscribe to the message from step 3. This should be done properly using the construction like:

this.sandbox.subscribe("GetMainContactEmail", this.getMainContactEmail, this,
						[this.getDetailId("UsrSchemabfb885cbDetail7d4ca999")]);

where 

 

getMainContactEmail will be the message handler method (the one method that will be called when the message is received);

UsrSchemabfb885cbDetail7d4ca999 will be the detail Id of the detail where multiple adding was developed (name of the detail from the "details" object in the main record schema).

5) In the message handler method from step 4 write a code to rertrieve current record address type and return it.

6) In the detail schema inside the init method execution send the message from step 1 via sandbox and assign the result of this message sending for some variable (something like):

var result = this.sandbox.publish("GetMainContactEmail", null, [this.sandbox.id]);

7) In the detail schema check if something was returned by the method handler from step 5 for the message sent from step 6. If there is something returned - set the returned value to the attribute from step 2.

8) Override the openLookupWithMultiSelect method and add additional filter using the value from the attribute from step 2 that was written to the attribute at step 7.

 

As a result when you open the modal box to bulk add records to the detail not all the records will be returned, but only those that fit filtering conditions developed in the steps above.

Oleg Drobina,

Excellent. Thanks Oleg!

I'll give this a try and get back to you.

By way of an epilogue and for anyone who happens this way in the future.

 

To filter the lookup add the following method to the detail source code (ref.  Creatio Academy):

//  Filter the lookup entries.
getAdditionalLookupFilters: function() {
	var filterGroup = new this.Terrasoft.createFilterGroup();
	filterGroup.add("ByCaseStatusFilter", this.Terrasoft.createColumnFilterWithParameter(
		this.Terrasoft.ComparisonType.EQUAL, "AddressType", "7a5d8cdb-54d6-46ce-8b5c-a4a9b319dbb7")
	);
	return filterGroup;
}

This overrdes the method in LookupMultiAddMixin.js.

Show all comments