Question

Business rule - filter values by current object Id

Hi,

I have a detail called 'contact in project' on the project page (contains link to contact and link to project and some more fields)

I want to add a lookup field called 'email contact' and allow users pick a contact from the contacts in project list.

I'm trying to add a business rule to the project page to filter the new field (email contact) to only show records associated with the current project.

I tried EmailContact.Project == project, but I don't seem to have the project Id on the list of objects in the business rules design section.

Any idea why the project doesn't appear there? (I can see all other connected objects and other fields but not the project itself)

Any other way to implement the filter?

Thanks in advanced

Chani

Like 0

Like

1 comments

Hi Chani,

 

On the ProjectPageV2 you need to create an attribute using the example below:

"UsrEmailContact": {
				"dataValueType": Terrasoft.DataValueType.LOOKUP,
				"lookupListConfig": {
					"filter": function() {
						var projectId = this.get("Id");
						var contactFilter = this.Ext.create("Terrasoft.FilterGroup");
						var projectIdFilter = Terrasoft.createExistsFilter("[UsrContactInProject:UsrContactInProjectDetailContact].Id");
						projectIdFilter.subFilters.addItem(Terrasoft.createColumnFilterWithParameter(
					Terrasoft.ComparisonType.EQUAL, "Project", projectId));
						contactFilter.addItem(projectIdFilter);
						return contactFilter;
					}
				}
			}

In my case:

 

UsrEmailContact - is the code for the lookup column on the project page;

UsrContactInProject - name of the object that represents the detail on the project page;

UsrContactInProjectDetailContact - is the code for the lookup column in the detail;

Project - is the name of the lookup column for the project reference (detail to object connection column name)

 

As a result this filter will return only contacts that are mentioned in the detail for the project record that is currently opened.

 

Best regards,

Oscar

Show all comments