I have added a new custom field in CMS_UserSettings table. The form control type is Multiple Choice. The data source for the control is set to a SQL Query. I would like to be able to populate the items in the control based on the selected user (Administration > Users). NOT the current user. Anyone know the syntax for this? Is it possible?
Here's my sample which pulls in the current users attribute. I need this to be the selected user.
SELECT ItemID, dealerNumber + ' - ' + dealerTitle
FROM cPort_DealerLocation
WHERE culliganGroupID = {%CurrentUser.culliganGroupID#%}
ORDER BY ItemID
You can access currently edited object through EditedObject macro - {%EditedObject.FieldName%}.
Edit:
It seems that a custom macro method is needed to do this for documents. I was able to do this by following code:
1) Create custom macro method (for how to do it see the documentation
MacroMethod method = new MacroMethod("MyEditedDoc", parameters => CMSContext.EditedDocument)
{
Type = typeof(TreeNode),
Comment = "Returns currently edited document.",
MinimumParameters = 0
};
MacroMethods.RegisterMethod(method);
2) Then in field editor of a document type you can use {%MyEditedDoc().DocumentName#%} and it gets resolved on the Form tab.
Related
I am writing some scripting processes in C# to update a SharePoint Online list with data from a system database (there's a whole heap in between, but that's irrelevant).
The issue I am having is that when I add new records, they are being added without validation rules being applied by SharePoint e.g. you can add an entry that has a missing mandatory field which then shows up OnLine with a (!) Required placeholder.
In the example below, lets assume the list has these (text) fields all of which are tagged as mandatory.
Title
Address
Rating (Just a simple 3 letter code)
And then the script has the following to add a new item ..
ClientContext clientContext = new ClientContext("my sponline site url");
List myList = client.Web.Lists.GetByTitle("my list");
ListItemCreationInformation newRecContext = new ListItemCreationInformation();
ListItem newItem = myList.AddItem(newRecContext);
newRecord.Add("Title", "My Name");
newRecord.Add("Address", "My Address");
/* Removed for Testing validation*/
//newRecord.Add("Rating", "AAA");
newItem.Update();
clientContext.Load(newItem);
clientContext.ExecuteQuery();
If the "Rating" field is populated then all good, item gets added... but if the line is removed should it not raise an exception to say that a mandatory field (Rating) is not provided.
Why is the CSOM not checking for validity?
Edit: I am using the Microsoft.SharePointOnline.CSOM (v16.1.7115.1200) package from NuGet
None of the code object models apply those rules. They're strictly for the UI controls shown to users. This is by design.
Well, this is how Sharepoint works. If you add list items programmatically - by default it does not validate required fields. You should just keep it in mind (on other hand - you have more freedom). You can add your custom validation in place where you save item. Other way is to create list item event receiver for your list and add your validation in the ItemUpdating method.
So on my website, I have a changelog system that goes through the database querying what software he or she is assigned to and the latest changelog posts (much like a blog) but only for their assigned software.
I have created a web page to assign users to software (including roles etc.) however I cannot correctly call the DataValueField which is assigned during page load.
The binding table looks a bit like this (Comma separated list on here)
BindingId, SoftId, UserId
The user's table is the default ASP.net identity table along with the user roles etc.
The software table, however, is assigned a unique id of the total number of rows plus 1.
The code I have is as follows (Standerd ASP.net code for dropdownlist control nothing special there)
Dim tbladap As New UserDataSetTableAdapters.SoftwareTableAdapter
SoftDrop.DataSource = tbladap.GetAllData()
SoftDrop.DataTextField = "SoftName"
SoftDrop.DataValueField = "SoftId"
SoftDrop.DataBind()
The issue is that SoftDrop always has a SelectedValue of 1. Just for reference the insert query is below
tbladap.Insert(tbladap.GetData().Rows.Count + 1, SoftDrop.SelectedValue, UserDrop.SelectedValue)
Any help appreciated, thanks!
Fixed. Poor research prior to asking the question.
All the controls loaded on page load and I didn't include:
If Not Page.IsPostBack() Then
'Load the controls
End If
try using like this
tbladap.Insert(tbladap.GetData().Rows.Count + 1, SoftDrop.SelectedItem.Value, UserDrop.SelectedItem.Value)
try using SelectedItem.Text too
I create work items through the TFS api.
var type = project.WorkItemTypes["Bug"];
var workItem = new WorkItem(type)
{
History = "Created by OneTrueError incident #" + dto.OneTrueErrorIncidentId,
Title = dto.Title,
Description = dto.StackTrace,
};
workItem.Fields["Activity"].Value = dto.Activity;
workItem.Fields["Repro Steps"].Value = dto.StepsToReproduce;
workItem.Links.Add(new Hyperlink(someBaseUri + "/issue/" + dto.OneTrueErrorIncidentId));
workItem.Save();
At a later point I want to be able to fetch a specific work item by querying on a Hyperlink that I attached when creating the work item.
I can't figure out how to write that query. All examples I've found regarding links are for links to other work items or TFS resources. I have had no luck trying to modify those examples.
So how can I find a specific workitem using WIQL and a specific Hyperlink.Location?
Unfortunately, it's not able to directly use hyperlink url info in WIQL. You could only use Hyperlink Count field which returns the number of hyperlinks that are defined for the work item.
Reference Name=System.HyperLinkCount, Data type=Integer
As a workaround you may have to get a list of worktiems with links and go through all returned info to match the url that your attached when creating the work item. Then get the work item.
I've been given a task to make a dynamic drop down which takes it's data[image and value id] from table. I am wondering if any of you came across this scenario or if any one can help me out in this I need help in concept and coding. Definitely any help is appreciated.
I see the example in jquery here is the link:
http://www.marghoobsuleman.com/jquery-image-dropdown
something like this but data is coming from table.
If you use the plugin that you found in the link, then basically what you will want to do is create the dropdown dynamically based on the table content. Without having more details of how your table is structured I can't give you exact details, but something like this should get you close (I'm going to assume there is a drop-down element already on the page somewhere called "select", and your table is called "table" with the image in field 0, and the text in field 1) Note: This hasn't really been tested.
var options = "";
$("#table tr").each(function() {
var imagePath = $(this).find("td:eq(0) img").attr("src");
var title = $(this).find("td:eq(1)").text();
options += '<option value="'+title+'" title="'+imagePath+'">'+title+'</option>';
});
$("#select").html(options);
OK so I've got 2 tables for this instance, Users{UserID, Name}, Company{CompanyID, UserID, Name, Payrate}
i also have 2 combo boxes, first one is for Users which Displays Name, and the Value is UserID
i need the second combobox to get the Names from the Company table, but only showing Companies that are relevant to the selected user. I cant work out how to get it to go...
Any ideas???
What language? C#, VB.NET ? Is this a web app or Windows app? Do you have associations setup in your datacontext to link Company.UserID (child) back to Users.UserID (parent) ?
if it's asp.net and on .net 4, there's some new support for doing the filtering declaratively
if you can't or don't want to use that, then i'd make sure you're using a linqdatasource to populate and use the Selecting event on the LinqDataSource - in there, you can set e.Result to the specific linq query you want to return (against the company table, i assume), which in your case will include a 'where' for filtering to the UserID (selected value) from the other combobox
here is how you can do it.
"cbat" is the comobox
var cat = from s in db.categories select new{s.name};
this.cbcat.ItemsSource = cat.ToList();
cbcat.DisplayMemberPath = "name";
cbcat.SelectedIndex = 0;