<?xml version="1.0" encoding="utf-16"?><customize><COR_CUSTOM_FIELD U_RuleName="DOC_10182: Custom Choose From List" U_Type="0" U_Action="0" U_Warning="N" U_WarningText="" U_WarningBox="N" U_WarningStatus="N" U_Active="Y" U_FormTypeBasis="" U_ItemUIDBasis="" U_ColumnBasis="" U_FormType="149,139,131,133,141,142,181,60092,65301,65309,182" U_ItemUID="38" U_Column="1" U_EventType="27" U_Before="Y" U_Mode="-1" U_Refresh="N" U_EasyFunctionRule="" U_Creator="" U_LastModified="16.08.2012 17:45:38" U_LastModifiedBy="1" U_Permission="111111111111111" U_ErrorBox=" " U_ErrorStatus=" "><U_Expression>/****** General Information *****Creator: coresystems ag, map@coresystems.chCreate Date: 2012-08-15 ***** StartConfDesc *****Adjust SAP Business One Choose From List***** EndConfDesc ***** ***** Updates *****2012-08-15, muf: Initial Rule*/string ruleName = pVal.RuleInfo.RuleName.ToString();string errorMessage = "Error in Optimizer Rule '" + ruleName + "'";try{	//StatusBar.WriteWarning(ruleName + "was triggered.");	/* Parameters to adjust */ 		string formDescription = "Item Selection";	// TODO: write here the main query that should be executed without filtering	string query = "SELECT ItemCode, ItemName FROM OITM"; 	if (pVal.Item is Matrix)	{		string val = ((Matrix) pVal.Item).GetValue(pVal.ColUID, pVal.Row - 1);		if (!String.IsNullOrEmpty(val))			return true;	}	else if (pVal.Item is TextEdit)	{		string val = ((TextEdit) pVal.Item).Value;		if (!String.IsNullOrEmpty(val))			return true;	}	string salt = SwissAddonFramework.Utils.UniqueStringGenerator.Next();	Form f = Form.CreateNewForm("F1", "F1_" + salt);	f.Value = formDescription;	f.Top = pVal.Form.Top + 50;	f.Left = pVal.Form.Left + 50;	f.DefButton = "1"; 	TextEdit txtFind = TextEdit.CreateNew("T1");	txtFind.SetPosition(10, 10);	txtFind.Width = 100; 	Grid g = Grid.CreateNew("G1");	g.SetSizeAndPosition(10, 50, f.Width - 50, f.Height - 100);	g.SelectionMode = SwissAddonFramework.UI.Components.Grid.SelectionModes.Auto;	g.Enabled = false; 	Button bOK = Button.CreateNew("1");	bOK.SetPosition(10, g.Top + g.Height + 5); 	Button bCancel = Button.CreateNew("2");	bCancel.SetPosition(bOK.Left + bOK.Width + 10, bOK.Top); 	f.AddItem(txtFind);	f.AddItem(g);	f.AddItem(bOK);	f.AddItem(bCancel);	f.Load(); 	g.ExecuteQuery(query); 	SwissAddonFramework.UI.EventHandling.ItemEvents.KeyDownEventHandler delKeyDown = null;	delKeyDown = delegate (SwissAddonFramework.UI.EventHandling.ItemEvents.KeyDown ev2)		{		f.Freeze(true);		string tmp = null;		try {			// TODO: here you can apply a filter when the user starts typing on the search field			tmp = query + " WHERE ItemCode LIKE '%" + txtFind.Value + "%'"; 			// at this stage the query would look like: 			// SELECT ItemCode, ItemName FROM OITM WHERE ItemCode LIKE '%mySearch%'			g.ExecuteQuery(tmp);		}		catch (Exception ex2)		{			StatusBar.WriteError(errorMessage + " - Query error: " + tmp);			Debug.WriteMessage(errorMessage + " - Query error: " + tmp, Debug.DebugLevel.Exception);		}		f.Freeze(false);		};		txtFind.AddHandler_KeyDown(SwissAddonFramework.UI.Components.ModeComponent.FormModes.ALL, null, delKeyDown); 		SwissAddonFramework.UI.EventHandling.ItemEvents.ItemPressedEventHandler delItemPressed = null;		delItemPressed = delegate (SwissAddonFramework.UI.EventHandling.ItemEvents.ItemPressed ev)			{			try 			{				string[] itemCodeList = new string[g.SelectedRows.Count]; 				for (int index = 0; index &lt; g.SelectedRows.Count; index++)				{					// TODO: here write the column that should be written back to the item where the action has been triggered.					itemCodeList[index] = g.GetValue("ItemCode", g.SelectedRows.RowIndex(index));					// In this case the column "ItemCode".					// This MUST match one of the columns returned by the query.				}				f.Close(); 				if (pVal.Item is Matrix)				{					Matrix m = (Matrix) pVal.Item;					for (int index = 0; index &lt; itemCodeList.Length; index++)					{						m.SetValue(pVal.ColUID, pVal.Row - 1 + index, itemCodeList[index]);					}				}				else if (pVal.Item is TextEdit)				{					TextEdit tx = (TextEdit) pVal.Item;					tx.Value = itemCodeList[0];				}			}			catch (Exception ex)			{				StatusBar.WriteError(errorMessage + ": " + ex.Message);				Debug.WriteMessage(errorMessage + ": " + ex.Message, Debug.DebugLevel.Exception);			}			};			bOK.AddHandler_ItemPressed(SwissAddonFramework.UI.Components.ModeComponent.FormModes.ALL, delItemPressed);}catch(System.Exception ex){	StatusBar.WriteError(errorMessage + ": " + ex.Message);	Debug.WriteMessage(errorMessage + ": " + ex.Message, Debug.DebugLevel.Exception);}return false;</U_Expression></COR_CUSTOM_FIELD></customize>