I am building an application consisting of Azure functions, working with the Graph API. A part of the code is creating columns in a SharePoint document library, just like described in the sample here:
https://learn.microsoft.com/en-us/graph/api/list-post-columns?view=graph-rest-1.0
It works completely fine if I am creating text, datetime, boolean or number types of columns, but when I try to create a HyperlinkOrPicture column, I get the following error:
Code: invalidRequest
Message: Invalid request
Inner error:
AdditionalData:
date: 2022-05-10T12:37:54
request-id: xxx
client-request-id: xxx
ClientRequestId: xxx
Here is a sample of the code I am using:
ColumnDefinition clLink = new ColumnDefinition
{
Name = "testLink",
DisplayName = "testLink",
HyperlinkOrPicture = new HyperlinkOrPictureColumn { IsPicture = false }
};
if (columns.Any(cl => String.Compare(cl.Name, clLink.Name, true) == 0) == false)
{
await graphClient.Sites[_siteID].Lists[_listID].Columns
.Request()
.AddAsync(clLink);
}
The Graph package I am using has the version 4.27.0.
What am I doing incorrectly? Any help would be appreciated.
Related
I am querying Azure DocumentDb (cosmos) for a document that is present in the container:
try{
doc = await client.ReadDocumentAsync(
GetDocumentUri("tenantString-campaignId"),
new RequestOptions
{
PartitionKey = new PartitionKey(tenantString)
});
}
catch(Exception e)
{
Console.WriteLine(e);
}
for this document:
tenantString-campaignId is the id you can see here and tenantString alone is the partition key this is under. The tenant itself was passed in as a string and I had that working but now I have changed to passing a Tenant object and parsing the string required from it I am not returning the document.
I have tried a few different variations of tenantString and id and I can generate either a DocumentClientException, Id does not exist, Exception or it fails silently; no exception and returns to the calling method where it causes a NullReferenceException as no document is returned.
As far as I can make out from debugging through this I am constructing all my data correctly and yet no document is returned. Does anyone have any idea what I can try next?
This syntax for the .NET SDK v2 is not correct. ReadDocumentAsync() should look like this.
var response = await client.ReadDocumentAsync(
UriFactory.CreateDocumentUri(databaseName, collectionName, "SalesOrder1"),
new RequestOptions { PartitionKey = new PartitionKey("Account1") });
You can see more v2 samples here
I have the following code where I want to add two post entries prior to saving:
ticket.Open();
var post = new Post
{
TicketId = dto.TicketId,
PostContent = "Ticket status changed to Open",
IsAutomatic = true
};
ticket.AddPost(post);
post = new Post
{
TicketId = dto.TicketId,
PostContent = HttpUtility.HtmlEncode(dto.Comments)
};
ticket.AddPost(post);
var notification = Notification.TicketReopened(post);
_unitOfWork.Complete();
A post belongs to a ticket. A notification is for a post.
However I get the following error:
Unable to determine the principal end of the 'Notification_Post' relationship. Multiple added entities may have the same primary key.
The only way I can fix is by calling _unitOfWork.Complete() after adding the first post and then calling it again at the end.
_unitOfWork.Complete() simply does the following:
public void Complete()
{
_context.SaveChanges();
}
However I need to complete the entire transaction as a whole.
How can I fix?
//get full list of active employees
public static object EmployeeList()
{
string traceFile = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var empList = (from emp in dbViews.EmployeeList
where emp.StatusID == 7
orderby emp.EmpNo
select new
{
emp.id,
emp.Name,
emp.EmpNo,
emp.Telephone,
emp.EmployeeType,
emp.DepartmentName,
emp.Supervisor,
emp.ImmediateSupervisor,
emp.StatusID
});
File.AppendAllText(traceFile, ((ObjectQuery)empList).ToTraceString());
return empList.ToList();
}
When executing the above code, am getting the error below and am not sure why
*
Unable to cast object of type
'System.Data.Entity.Infrastructure.DbQuery1[<>f__AnonymousType09[System.Int32,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.Nullable`1[System.Int32]]]'
to type 'System.Data.Objects.ObjectQuery'.
*
I just want to get the real T-SQL generated by the above Entity Framework code.
The error is at line below
File.AppendAllText(traceFile, ((ObjectQuery)empList).ToTraceString());
You are using DbContext API so you can use just empList.ToString().
We are working with Fast Search for Sharepoint 2010 and had some backend setup done with creating some managed properties e.g. BestBetDescription, keywords etc.
From the front-end part we are creating an application what will fetch all these properties and display in a grid.
However while querying the backend we are NOT getting these managed properties (BestBetDescription) along with other properties such as Title, URL etc.
Following is my source code:
settingsProxy = SPFarm.Local.ServiceProxies.GetValue<SearchQueryAndSiteSettingsServiceProxy>();
searchProxy = settingsProxy.ApplicationProxies.GetValue<SearchServiceApplicationProxy>("FAST Query SSA");
keywordQuery = new KeywordQuery(searchProxy);
keywordQuery.EnableFQL = true;
keywordQuery.QueryText = p;
keywordQuery.ResultsProvider = SearchProvider.FASTSearch;
keywordQuery.ResultTypes = ResultType.RelevantResults;
ResultTableCollection resultsTableCollection = keywordQuery.Execute();
ResultTable searchResultsTable = resultsTableCollection[ResultType.RelevantResults];
DataTable resultsDataTable = new DataTable();
resultsDataTable.TableName = "Results";
resultsDataTable.Load(searchResultsTable, LoadOption.OverwriteChanges);
return resultsDataTable;
The results are returned and I cannot see the Managed properties which we create in the resultDataTable.
Is there any property I missed or is this a backend issue ?
Thanks.
Hi if you are creating your custom Metadata Property then u should use this option to be selected
please check below link
http://screencast.com/t/SQdlarjhx4F
You can find this option in :
central admin:- services :- fast search :- Metadata Property :- your property
I was missing a property KeywordQuery.SelectProperties
So the code looks something like this
String[] arrSearchProperties = new String[] { "Title", "body", "url" };
KeywordQuery.SelectProperties(arrSearchProperties);
This will fetch you all the Managed Properties defined by you.
I am having trouble with a MOSS FulltextSqlQuery when attempting to filter People results on the Skills Managed Property using the CONTAINS predicate. Let me demonstrate:
A query with no filters returns the expected result:
SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')
Result
Total Rows: 1
ACCOUNTNAME: MYDOMAIN\Bob
SKILLS: Numchucks | ASP.Net | Application Architecture
But when I append a CONTAINS predicate, I no longer get the expected result:
SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')
And (CONTAINS(Skills, 'Numchucks'))
Result
Total Rows: 0
I do realize I can accomplish this using the SOME ARRAY predicate, but I would like to know why this is not working with the CONTAINS predicate for the Skills property. I have been successful using the CONTAINS predicate with a custom crawled property that is indicated as 'Multi-valued'. The Skills property (though it seems to be multi-valued) is not indicated as such on the Crawled Properties page in the SSP admin site:
http:///ssp/admin/_layouts/schema.aspx?ConsoleView=crawledPropertiesView&category=People
Anyone have any ideas?
So with the help of Mark Cameron (Microsoft SharePoint Developer Support), I figured out that certain managed properties have to be enabled for full text search using the ManagedProperty object model API by setting the FullTextQueriable property to true. Below is the method that solved this issue for me. It could be included in a Console app or as a Farm or Web Application scoped Feature Receiver.
using Microsoft.Office.Server;
using Microsoft.Office.Server.Search.Administration;
private void EnsureFullTextQueriableManagedProperties(ServerContext serverContext)
{
var schema = new Schema(SearchContext.GetContext(serverContext));
var managedProperties = new[] { "SKILLS", "INTERESTS" };
foreach (ManagedProperty managedProperty in schema.AllManagedProperties)
{
if (!managedProperties.Contains(managedProperty.Name.ToUpper()))
continue;
if (managedProperty.FullTextQueriable)
continue;
try
{
managedProperty.FullTextQueriable = true;
managedProperty.Update();
Log.Info(m => m("Successfully set managed property {0} to be FullTextQueriable", managedProperty.Name));
}
catch (Exception e)
{
Log.Error(m => m("Error updating managed property {0}", managedProperty.Name), e);
}
}
}
SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')
And (CONTAINS(Skills, 'Numchucks*'))
use the * in the end.
You also have a few more options to try:
The following list identifies
additional query elements that are
supported only with SQL search syntax
using the FullTextSqlQuery class:
FREETEXT()
CONTAINS()
LIKE
Source