Фильтр поля с помощью значка молния

Здраствуйте,

Как можно настроит так что бы, при выборе ответственного (поле "Ответсвенный" = раздел "Контакт") фильтровалось поле группа (поле "Группа" = справочник "Объект Администрирование") с помощью значка молния на карточке активности (тип "Задача")? (прик. файл)

Заранее большое спосиба.

С уважением,

Нравится

3 комментария

Такую реализацию можно посмотреть в BPMonline Sevice Desk 5.X, карточка инцидента BaseServiceRequestInBPMonlineEditPage, сервис фильтруется по сервисному договору.

Там, в частности используются функции.

Первая — получает список отфильтрованных по сервисному договору сервисов:

RecordData[] GetAvailableServicesNew(Guid serviceAgreementId){
if (serviceAgreementId == Guid.Empty) {
	return null;
}
var resultList = new List<RecordData>();
var serviceIdsList = new List<Guid>();
 
var entitySchemaManager = UserConnection.GetSchemaManager("EntitySchemaManager") as EntitySchemaManager;
//in packages
var serviceInServiceAgreementSchemaQuery = new EntitySchemaQuery(entitySchemaManager, "ServiceInServiceAgreement");
var serviceIdQueryColumnName = serviceInServiceAgreementSchemaQuery.AddColumn("Service.Id").Name;
var serviceNameQueryColumnName = serviceInServiceAgreementSchemaQuery.AddColumn("Service.ServiceName").Name;
var packageNameQueryColumnName = serviceInServiceAgreementSchemaQuery.AddColumn("ServicePackage.Name").Name;
var serviceAgreementFilter = serviceInServiceAgreementSchemaQuery.CreateFilterWithParameters(FilterComparisonType.Equal, "ServiceAgreement.Id", serviceAgreementId);
var typeFilter = serviceInServiceAgreementSchemaQuery.CreateFilterWithParameters(FilterComparisonType.Equal, "Type.Id", new Guid("f3b90f08-f46b-1410-809e-00155d852b12"));
var packageNotNullFilter = serviceInServiceAgreementSchemaQuery.CreateIsNotNullFilter("ServicePackage");
var activeFilter = serviceInServiceAgreementSchemaQuery.CreateFilterWithParameters(FilterComparisonType.Equal, "Service.Status.Active", true);
IEntitySchemaQueryFilterItem filter = null; 
object[] serviceRequestTypeServiceIds = null;
if (string.IsNullOrEmpty(VirtualEntitySchemaName)) {
	filter = new EntitySchemaQueryFilterCollection(serviceInServiceAgreementSchemaQuery, LogicalOperationStrict.And, serviceAgreementFilter, typeFilter, packageNotNullFilter, activeFilter);	
}
else {
	serviceRequestTypeServiceIds = GetServicesForServiceRequestTypeByServiceAgreement(serviceAgreementId);
	IEntitySchemaQueryFilterItem serviceRequestTypeFilter;
	if (serviceRequestTypeServiceIds.Length == 0 ) {
		//HACK
		serviceRequestTypeFilter = serviceInServiceAgreementSchemaQuery.CreateFilterWithParameters(FilterComparisonType.Equal, "Service.Id", Guid.NewGuid());
	}
	else {
		serviceRequestTypeFilter = serviceInServiceAgreementSchemaQuery.CreateFilterWithParameters(FilterComparisonType.Equal, "Service.Id", serviceRequestTypeServiceIds);
	}	 
	filter = new EntitySchemaQueryFilterCollection(serviceInServiceAgreementSchemaQuery, LogicalOperationStrict.And, serviceAgreementFilter, typeFilter, packageNotNullFilter, activeFilter, serviceRequestTypeFilter);	
}
serviceInServiceAgreementSchemaQuery.Filters.Add(filter);
var servicesInServiceAgreement = serviceInServiceAgreementSchemaQuery.GetEntityCollection(UserConnection);
foreach (var serviceInServiceAgreement in servicesInServiceAgreement) {
	var serviceId = serviceInServiceAgreement.GetTypedColumnValue<Guid>(serviceIdQueryColumnName);
	if (!serviceIdsList.Contains(serviceId)) {
		var serviceName = serviceInServiceAgreement.GetTypedColumnValue<string>(serviceNameQueryColumnName);
		var packageName = serviceInServiceAgreement.GetTypedColumnValue<string>(packageNameQueryColumnName);
		var recordData = new RecordData();
		recordData.Id = serviceId;
		recordData.Name = string.Concat(serviceName, " (", packageName, ")");
		resultList.Add(recordData);
		serviceIdsList.Add(serviceId);
	}
}
//just services
serviceInServiceAgreementSchemaQuery = new EntitySchemaQuery(entitySchemaManager, "ServiceInServiceAgreement");
serviceIdQueryColumnName = serviceInServiceAgreementSchemaQuery.AddColumn("Service.Id").Name;
serviceNameQueryColumnName = serviceInServiceAgreementSchemaQuery.AddColumn("Service.ServiceName").Name;
serviceAgreementFilter = serviceInServiceAgreementSchemaQuery.CreateFilterWithParameters(FilterComparisonType.Equal, "ServiceAgreement.Id", serviceAgreementId);
typeFilter = serviceInServiceAgreementSchemaQuery.CreateFilterWithParameters(FilterComparisonType.Equal, "Type.Id", new Guid("f3b90f08-f46b-1410-809e-00155d852b12"));
var packageNullFilter = serviceInServiceAgreementSchemaQuery.CreateIsNullFilter("ServicePackage");
activeFilter = serviceInServiceAgreementSchemaQuery.CreateFilterWithParameters(FilterComparisonType.Equal, "Service.Status.Active", true);
filter = new EntitySchemaQueryFilterCollection(serviceInServiceAgreementSchemaQuery, LogicalOperationStrict.And, serviceAgreementFilter, typeFilter, packageNullFilter, activeFilter);	
if (!string.IsNullOrEmpty(VirtualEntitySchemaName)) {
	serviceRequestTypeServiceIds = GetServicesForServiceRequestTypeByServiceAgreement(serviceAgreementId);
	IEntitySchemaQueryFilterItem serviceRequestTypeFilter;
	if (serviceRequestTypeServiceIds.Length == 0) {
		//HACK
		serviceRequestTypeFilter = serviceInServiceAgreementSchemaQuery.CreateFilterWithParameters(FilterComparisonType.Equal, "Service.Id", Guid.NewGuid());
	}
	else {
		serviceRequestTypeFilter = serviceInServiceAgreementSchemaQuery.CreateFilterWithParameters(FilterComparisonType.Equal, "Service.Id", serviceRequestTypeServiceIds);
	}
	filter = new EntitySchemaQueryFilterCollection(serviceInServiceAgreementSchemaQuery, LogicalOperationStrict.And, filter, serviceRequestTypeFilter);
}
serviceInServiceAgreementSchemaQuery.Filters.Add(filter);
servicesInServiceAgreement = serviceInServiceAgreementSchemaQuery.GetEntityCollection(UserConnection);
foreach (var serviceInServiceAgreement in servicesInServiceAgreement) {
	var serviceId = serviceInServiceAgreement.GetTypedColumnValue<Guid>(serviceIdQueryColumnName);
	if (!serviceIdsList.Contains(serviceId)) {		
		var recordData = new RecordData();
		recordData.Id = serviceId;
		recordData.Name = serviceInServiceAgreement.GetTypedColumnValue<string>(serviceNameQueryColumnName);
		resultList.Add(recordData);
		serviceIdsList.Add(serviceId);
	}
}
return resultList.ToArray();
}

Вторая — строит меню у кнопки:

void SetServiceToolButtonStateNew(LookupEdit serviceLookupEdit, ToolButton serviceLookupToolButton, RecordData[] availableServices){
CreateToolButtonMenuNew(serviceLookupEdit, serviceLookupToolButton, availableServices, "ShowAllServices", AllServicesInAgreementCaption.ToString(), false);
}
 
 
void CreateToolButtonMenuNew(LookupEdit lookupEdit, ToolButton toolButton, RecordData[] availableItems, string allItemsMessage, string allItemsCaption, bool showIfOneRecord) {
toolButton.Menu.Clear();
Page.AddScript(string.Format("{0}.getMenu().removeAll();", toolButton.ClientID));
if (availableItems == null) {
	toolButton.Hidden = true;
	return;
}
var n = availableItems.Length;
var minN = showIfOneRecord ? 1 : 2;
if (n >= minN) {
	toolButton.Hidden = false;	
	var m = Math.Min(n, 10);
	if (n > 10) {
		m = 9;
	}
	for (var i = 0; i < m; i++) {
		var recordData = availableItems[i];				
		var menuItem = new Terrasoft.UI.WebControls.Controls.MenuItem();
		menuItem.Caption = recordData.Name;
		menuItem.CreatedByAjax = true;
		menuItem.EnableViewState = false;
		menuItem.Name = string.Concat(allItemsMessage, "MenuItem", i.ToString());
		menuItem.UId = Guid.NewGuid();
		menuItem.Image = GetServiceObjectIconNew(recordData);
    	toolButton.Menu.Add(menuItem);
		//HACK
		//Page.AddScript(string.Format("{0} = {{}};{0}.setImage=Ext.emptyFn;", menuItem.ClientID));
		menuItem.AllowCallbackScriptMonitoring = false;
		var script = string.Format("window.{0} = {1};\n", menuItem.ClientID, menuItem.GenerateControlScript(true, null));
    	script += string.Format("{0}.getMenu().addItem(window.{1});\n", toolButton.ClientID, menuItem.ClientID);
		script += string.Format("{0}.on('click', function() {{ {1}.setValueAndText('{2}', '{3}'); }}, this);\n", menuItem.ClientID, lookupEdit.ClientID, recordData.Id.ToString(), recordData.Name.Replace("'", @"\'").Replace("\""

А можно ли если не трудно прописать скрипт более детально? А то я что-то не поняла...

С уважением,

Лучше посмотрите целиком в карточке, если есть возможность посмотреть на Service Desk.

Показать все комментарии