Reputation: 11
I have declared: ListItem contractItem; A process that retrieves data from SQL fills contractItem.
contractItem is then written back to SQL.Works weel. All info in contractItem is as expected.
But, i need to write certain values in contractItem to a log-file.
String sTxt = "Subject = " + contractItem.FieldValues["Subject"].ToString();
The contents of sTxt = "Subject = Microsoft.SharePoint.Client.FieldLookupValue"
instead of what I expected it to be: "Subject = Documentation e-content 365"
What am I doing wrong?
String sTxt = "Subject = " + contractItem.FieldValues["Subject"].ToString();
or
String sTxt = "Subject = " + contractItem.FieldValues["Subject"];
both result in "Subject = Microsoft.SharePoint.Client.FieldLookupValue"
Upvotes: 1
Views: 71
Reputation: 1499760
The result of contractItem.FieldValues["Subject"]
is apparently a FieldLookupValue
and apparently that doesn't override ToString()
. However, it does expose a LookupValue
property.
So I suspect you want something like:
var lookup = (FieldLookupValue) contractItem.FieldValues["Subject"];
string subject = lookup.LookupValue;
strinug text = "Subject = " + subject; // Or just $"Subject = {subject}"
Upvotes: 2