public AxSearchBox(sfPartner.Field f) { InitializeComponent(); _f = f; _d = Globals.ThisAddIn.getData(); // TODO for now assume that we are looking up by the Name field // this isn't always true, e.g. Task is Subject *but* the only way to do it // is to load the full definition of the object from Salesforce and step through all the // fields and find the one with nameField set to true - I'm actually doing that for the // object that we load but would need to look up the others when we get a reference _namefield = "Name"; //If it can only be one object then hide the object picker if (f.referenceTo.Length == 1) { o1.Visibility = System.Windows.Visibility.Collapsed; coldefo1.Width = new GridLength(0); } //Otherwise populate o1.Items.Clear(); foreach (string s in f.referenceTo) { RadComboBoxItem cbi = new RadComboBoxItem(); cbi.Tag = s; cbi.Content = _d.GetSObjectDef(s).label; // hard code overide for the Group versus Queue // can't work out how this is filtered and where you can find it in the object definition or layout // definition just says "Group" but UI says Queue and shows Groups where Type = Queue - odd! // also the Type is returned as Queue from the SOQL if (s == "Group") { cbi.Tag = "Queue"; cbi.Content = "Queue"; } o1.Items.Add(cbi); } //set to the first one *might be a default - should use that _type = f.referenceTo[0]; _typeName = _d.GetSObjectDef(_type).label; //Set special filter acb1.FilteringBehavior = new ShowAllFilteringBehavior(); _gotdata = false; _triggerevents = true; }
// go though each of the PickLists and remove any of the entries that aren't available // for this record type mapping void UpdatePickLists(sfPartner.RecordTypeMapping rtm) { StackPanel CurrentSPFields = (StackPanel)FieldContent.Content; for (int i = 0; i < CurrentSPFields.Children.Count; i++) { if (CurrentSPFields.Children[i].GetType() == typeof(Telerik.Windows.Controls.GroupBox)) { Telerik.Windows.Controls.GroupBox gb = (Telerik.Windows.Controls.GroupBox)CurrentSPFields.Children[i]; Grid g = (Grid)gb.Content; for (int j = 0; j < g.Children.Count; j++) { if (g.Children[j].GetType() == typeof(StackPanel)) { StackPanel spcontrol = (StackPanel)g.Children[j]; foreach (Control spchildControl in spcontrol.Children) { Control childControl = spchildControl; if (childControl.GetType() == typeof(RadComboBox)) { Telerik.Windows.Controls.RadComboBox cb = (Telerik.Windows.Controls.RadComboBox)childControl; if (cb.Tag != null) { string[] n = cb.Tag.ToString().Split('|'); string name = n[0]; if (name != "RecordTypeId") { foreach (sfPartner.PicklistForRecordType prt in rtm.picklistsForRecordType) { if (prt.picklistName == name) { // ok - step through the items in the picklist and see if they are here for (int z = 0; z < cb.Items.Count; z++) { if (cb.Items[z].GetType() == typeof(string)) { bool found = false; foreach (sfPartner.PicklistEntry entry in prt.picklistValues) { if (entry.value == cb.Items[z].ToString()) { found = true; } } if (!found) { cb.Items.RemoveAt(z); } } } } } } } } } } } } } }