static void CreateExpenseSiteColumns() { fldExpenseCategory = clientContext.CastTo <FieldChoice>(CreateSiteColumn("ExpenseCategory", "Expense Category", "Choice")); string[] choicesExpenseCategory = ExpenseCategory.GetAll(); fldExpenseCategory.Choices = choicesExpenseCategory; fldExpenseCategory.Update(); clientContext.ExecuteQuery(); fldExpenseDate = clientContext.CastTo <FieldDateTime>(CreateSiteColumn("ExpenseDate", "Expense Date", "DateTime"));; fldExpenseDate.DisplayFormat = DateTimeFieldFormatType.DateOnly; fldExpenseDate.Update(); fldExpenseAmount = clientContext.CastTo <FieldCurrency>(CreateSiteColumn("ExpenseAmount", "Expense Amount", "Currency")); fldExpenseAmount.MinimumValue = 0; fldExpenseBudgetYear = clientContext.CastTo <FieldText>(CreateSiteColumn("ExpenseBudgetYear", "Budget Year", "Text")); fldExpenseBudgetQuarter = clientContext.CastTo <FieldText>(CreateSiteColumn("ExpenseBudgetQuarter", "Budget Quarter", "Text")); fldExpenseBudgetQuarter.Update(); fldExpenseBudgetAmount = clientContext.CastTo <FieldCurrency>(CreateSiteColumn("ExpenseBudgetAmount", "Budget Amount", "Currency")); clientContext.ExecuteQuery(); }
static void CreateWingtipSiteColumns() { Console.WriteLine(); fieldProductCode = CreateSiteColumn("ProductCode", "Product Code", "Text"); fieldProductCode.EnforceUniqueValues = true; fieldProductCode.Indexed = true; fieldProductCode.Required = true; fieldProductCode.Update(); clientContext.ExecuteQuery(); clientContext.Load(fieldProductCode); clientContext.ExecuteQuery(); fieldProductDescription = clientContext.CastTo <FieldMultiLineText>(CreateSiteColumn("ProductDescription", "Product Description", "Note")); fieldProductDescription.NumberOfLines = 4; fieldProductDescription.RichText = false; fieldProductDescription.Update(); clientContext.ExecuteQuery(); fieldProductListPrice = clientContext.CastTo <FieldCurrency>(CreateSiteColumn("ProductListPrice", "List Price", "Currency")); fieldProductListPrice.MinimumValue = 0; fieldProductListPrice.Update(); clientContext.ExecuteQuery(); fieldProductColor = clientContext.CastTo <FieldMultiChoice>(CreateSiteColumn("ProductColor", "Product Color", "MultiChoice")); string[] choicesProductColor = { "White", "Black", "Grey", "Blue", "Red", "Green", "Yellow" }; fieldProductColor.Choices = choicesProductColor; fieldProductColor.Update(); clientContext.ExecuteQuery(); fieldMinimumAge = clientContext.CastTo <FieldNumber>(CreateSiteColumn("MinimumAge", "Minimum Age", "Number")); fieldMinimumAge.MinimumValue = 1; fieldMinimumAge.MaximumValue = 100; fieldMinimumAge.Update(); clientContext.ExecuteQuery(); fieldMaximumAge = clientContext.CastTo <FieldNumber>(CreateSiteColumn("MaximumAge", "Maximum Age", "Number")); fieldMaximumAge.MinimumValue = 1; fieldMaximumAge.MaximumValue = 100; fieldMaximumAge.Update(); clientContext.ExecuteQuery(); fieldProductImageUrl = clientContext.CastTo <FieldUrl>(CreateSiteColumn("ProductImageUrl", "Product Image Url", "URL")); fieldProductImageUrl.DisplayFormat = UrlFieldFormatType.Image; fieldProductImageUrl.Update(); clientContext.ExecuteQuery(); }
public FieldCurrencyInformation(FieldCurrency field) : base(field) { CurrencyLocaleId = field.CurrencyLocaleId; }
static void CreateWingtipSiteColumns() { Console.WriteLine(); fieldProductCode = CreateSiteColumn("ProductCode", "Product Code", "Text"); fieldProductCode.EnforceUniqueValues = true; fieldProductCode.Indexed = true; fieldProductCode.Required = true; fieldProductCode.Update(); clientContext.ExecuteQuery(); clientContext.Load(fieldProductCode); clientContext.ExecuteQuery(); fieldProductDescription = clientContext.CastTo<FieldMultiLineText>(CreateSiteColumn("ProductDescription", "Product Description", "Note")); fieldProductDescription.NumberOfLines = 4; fieldProductDescription.RichText = false; fieldProductDescription.Update(); clientContext.ExecuteQuery(); fieldProductListPrice = clientContext.CastTo<FieldCurrency>(CreateSiteColumn("ProductListPrice", "Product List Price", "Currency")); fieldProductListPrice.MinimumValue = 0; fieldProductListPrice.Update(); clientContext.ExecuteQuery(); fieldProductColor = clientContext.CastTo<FieldMultiChoice>(CreateSiteColumn("ProductColor", "Product Color", "MultiChoice")); string[] choicesProductColor = { "White", "Black", "Grey", "Blue", "Red", "Green", "Yellow" }; fieldProductColor.Choices = choicesProductColor; fieldProductColor.Update(); clientContext.ExecuteQuery(); fieldMinimumAge = clientContext.CastTo<FieldNumber>(CreateSiteColumn("MinimumAge", "Minimum Age", "Number")); fieldMinimumAge.MinimumValue = 1; fieldMinimumAge.MaximumValue = 100; fieldMinimumAge.Update(); clientContext.ExecuteQuery(); fieldMaximumAge = clientContext.CastTo<FieldNumber>(CreateSiteColumn("MaximumAge", "Maximum Age", "Number")); fieldMaximumAge.MinimumValue = 1; fieldMaximumAge.MaximumValue = 100; fieldMaximumAge.Update(); clientContext.ExecuteQuery(); }
static void CreateWingtipSiteColumns() { Console.WriteLine(); fieldProductCode = CreateSiteColumn("ProductCode", "Product Code", "Text"); fieldProductCode.EnforceUniqueValues = true; fieldProductCode.Indexed = true; fieldProductCode.Required = true; fieldProductCode.Update(); clientContext.ExecuteQuery(); clientContext.Load(fieldProductCode); clientContext.ExecuteQuery(); fieldProductDescription = clientContext.CastTo<FieldMultiLineText>(CreateSiteColumn("ProductDescription", "Product Description", "Note")); fieldProductDescription.NumberOfLines = 4; fieldProductDescription.RichText = false; fieldProductDescription.Update(); clientContext.ExecuteQuery(); fieldProductListPrice = clientContext.CastTo<FieldCurrency>(CreateSiteColumn("ProductListPrice", "List Price", "Currency")); fieldProductListPrice.MinimumValue = 0; fieldProductListPrice.Update(); clientContext.ExecuteQuery(); fieldProductCategory = clientContext.CastTo<TaxonomyField>(CreateSiteColumn("ProductCategory", "Product Category", "TaxonomyFieldType")); fieldProductCategory.SspId = localTermStoreID; fieldProductCategory.TermSetId = termSetId; fieldProductCategory.AllowMultipleValues = false; fieldProductCategory.Update(); clientContext.ExecuteQuery(); fieldProductColor = clientContext.CastTo<FieldMultiChoice>(CreateSiteColumn("ProductColor", "Product Color", "MultiChoice")); string[] choicesProductColor = { "White", "Black", "Grey", "Blue", "Red", "Green", "Yellow" }; fieldProductColor.Choices = choicesProductColor; fieldProductColor.Update(); clientContext.ExecuteQuery(); fieldMinimumAge = clientContext.CastTo<FieldNumber>(CreateSiteColumn("MinimumAge", "Minimum Age", "Number")); fieldMinimumAge.MinimumValue = 1; fieldMinimumAge.MaximumValue = 100; fieldMinimumAge.Update(); clientContext.ExecuteQuery(); fieldMaximumAge = clientContext.CastTo<FieldNumber>(CreateSiteColumn("MaximumAge", "Maximum Age", "Number")); fieldMaximumAge.MinimumValue = 1; fieldMaximumAge.MaximumValue = 100; fieldMaximumAge.Update(); clientContext.ExecuteQuery(); fieldProductImageUrl = clientContext.CastTo<FieldUrl>(CreateSiteColumn("ProductImageUrl", "Product Image Url", "URL")); fieldProductImageUrl.DisplayFormat = UrlFieldFormatType.Image; fieldProductImageUrl.Update(); clientContext.ExecuteQuery(); }
static void CreateWingtipSiteColumns() { Console.WriteLine(); Console.WriteLine("Creating site columns"); fieldProductCode = CreateSiteColumn("ProductCode", "Product Code", "Text"); fieldProductCode.EnforceUniqueValues = true; fieldProductCode.Indexed = true; fieldProductCode.Required = true; fieldProductCode.Update(); clientContext.ExecuteQuery(); clientContext.Load(fieldProductCode); clientContext.ExecuteQuery(); fieldProductListPrice = clientContext.CastTo<FieldCurrency>(CreateSiteColumn("ProductListPrice", "List Price", "Currency")); fieldProductCategory = clientContext.CastTo<FieldChoice>(CreateSiteColumn("ProductCategory", "Product Category", "Choice")); string[] choicesProductCategory = { "Action Figures", "Arts and Crafts", "Vehicles and Remote Control" }; fieldProductCategory.Choices = choicesProductCategory; fieldProductCategory.Update(); clientContext.ExecuteQuery(); fieldProductColor = clientContext.CastTo<FieldChoice>(CreateSiteColumn("ProductColor", "Product Color", "Choice")); string[] choicesProductColor = { "White", "Black", "Grey", "Blue", "Red", "Green", "Yellow" }; fieldProductColor.Choices = choicesProductColor; fieldProductColor.Update(); clientContext.ExecuteQuery(); fieldMinimumAge = clientContext.CastTo<FieldNumber>(CreateSiteColumn("MinimumAge", "Minimum Age", "Number")); fieldMaximumAge = clientContext.CastTo<FieldNumber>(CreateSiteColumn("MaximumAge", "Maximum Age", "Number")); }
public static void CreateOrderDetailsList() { Console.WriteLine("Creating order details list..."); if (OrdersListExists()) { ListCreationInformation listInformationOrderDetails = new ListCreationInformation(); listInformationOrderDetails.Title = "OrderDetails"; listInformationOrderDetails.Url = "Lists/OrderDetails"; listInformationOrderDetails.QuickLaunchOption = QuickLaunchOptions.On; listInformationOrderDetails.TemplateType = (int)ListTemplateType.GenericList; listOrderDetails = site.Lists.Add(listInformationOrderDetails); listOrderDetails.OnQuickLaunch = true; listOrderDetails.EnableAttachments = false; listOrderDetails.Update(); clientContext.ExecuteQuery(); listOrderDetails.DefaultView.ViewFields.RemoveAll(); listOrderDetails.DefaultView.ViewFields.Add("ID"); listOrderDetails.DefaultView.Update(); clientContext.ExecuteQuery(); var fldTitle = listOrderDetails.Fields.GetByInternalNameOrTitle("Title"); fldTitle.Required = false; fldTitle.Update(); clientContext.ExecuteQuery(); string fldOrderLookupXml = @"<Field Name='OrderId' DisplayName='Order' Type='Lookup' ></Field>"; FieldLookup fldOrderLookup = clientContext.CastTo <FieldLookup>(listOrderDetails.Fields.AddFieldAsXml(fldOrderLookupXml, true, AddFieldOptions.AddFieldInternalNameHint)); // add cusotmer lookup field fldOrderLookup.LookupField = "ID"; fldOrderLookup.LookupList = listOrders.Id.ToString(); fldOrderLookup.Indexed = true; fldOrderLookup.RelationshipDeleteBehavior = RelationshipDeleteBehaviorType.Cascade; fldOrderLookup.Update(); // add quantity field string fldQuantityXml = @"<Field Name='Quantity' DisplayName='Quantity' Type='Number' ></Field>"; FieldNumber fldQuantity = clientContext.CastTo <FieldNumber>(listOrderDetails.Fields.AddFieldAsXml(fldQuantityXml, true, AddFieldOptions.DefaultValue)); fldQuantity.Update(); // add product field string fldProductXml = @"<Field Name='Product' DisplayName='Product' Type='Text' ></Field>"; FieldText fldProduct = clientContext.CastTo <FieldText>(listOrderDetails.Fields.AddFieldAsXml(fldProductXml, true, AddFieldOptions.DefaultValue)); fldProduct.Update(); string fldSalesAmountXml = @"<Field Name='SalesAmount' DisplayName='SalesAmount' Type='Currency' ></Field>"; FieldCurrency fldSalesAmount = clientContext.CastTo <FieldCurrency>(listOrderDetails.Fields.AddFieldAsXml(fldSalesAmountXml, true, AddFieldOptions.DefaultValue)); fldSalesAmount.Update(); clientContext.ExecuteQuery(); //listOrderDetails.DefaultView.ViewFields.Remove("Title"); listOrderDetails.DefaultView.Update(); clientContext.ExecuteQuery(); } else { Console.WriteLine("Cannot create OrderDetails list because Orders list does not exist."); } }
public static void CreateOrdersList() { Console.WriteLine("Creating orders list..."); if (CustomersListExists()) { ListCreationInformation listInformationOrders = new ListCreationInformation(); listInformationOrders.Title = "Orders"; listInformationOrders.Url = "Lists/Orders"; listInformationOrders.QuickLaunchOption = QuickLaunchOptions.On; listInformationOrders.TemplateType = (int)ListTemplateType.GenericList; listOrders = site.Lists.Add(listInformationOrders); listOrders.OnQuickLaunch = true; listOrders.EnableAttachments = false; listOrders.Update(); clientContext.ExecuteQuery(); clientContext.Load(listOrders.DefaultView.ViewFields); clientContext.ExecuteQuery(); listOrders.DefaultView.ViewFields.RemoveAll(); listOrders.DefaultView.ViewFields.Add("ID"); listOrders.DefaultView.ViewFields.Add("Title"); listOrders.DefaultView.Update(); clientContext.ExecuteQuery(); string fldCustomerLookupXml = @"<Field Name='Customer' DisplayName='Customer' Type='Lookup' ></Field>"; FieldLookup fldCustomerLookup = clientContext.CastTo <FieldLookup>(listOrders.Fields.AddFieldAsXml(fldCustomerLookupXml, true, AddFieldOptions.DefaultValue)); // add cusotmer lookup field fldCustomerLookup.LookupField = "Title"; fldCustomerLookup.LookupList = listCustomers.Id.ToString(); fldCustomerLookup.Indexed = true; fldCustomerLookup.RelationshipDeleteBehavior = RelationshipDeleteBehaviorType.Cascade; fldCustomerLookup.Update(); // add order date field string fldOrderDateXml = @"<Field Name='OrderDate' DisplayName='OrderDate' Type='DateTime' ></Field>"; FieldDateTime fldOrderDate = clientContext.CastTo <FieldDateTime>(listOrders.Fields.AddFieldAsXml(fldOrderDateXml, true, AddFieldOptions.DefaultValue)); fldOrderDate.DisplayFormat = DateTimeFieldFormatType.DateOnly; fldOrderDate.Update(); // add order date field string fldOrderAmountXml = @"<Field Name='OrderAmount' DisplayName='OrderAmount' Type='Currency' ></Field>"; FieldCurrency fldOrderAmount = clientContext.CastTo <FieldCurrency>(listOrders.Fields.AddFieldAsXml(fldOrderAmountXml, true, AddFieldOptions.DefaultValue)); fldOrderAmount.Update(); clientContext.ExecuteQuery(); clientContext.Load(listOrders); clientContext.ExecuteQuery(); } else { Console.WriteLine("Cannot create Orders list because Customer list does not exist."); } }