[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SharePoint: Use C# or CAML to read contact person (etc) for current page.

Posted on 2011-10-21
3
Medium Priority
?
403 Views
Last Modified: 2012-05-12
I created custom web-part.  How can I read  (C# or CAML) contact person (i.e) for current page? This information would allow me to customize web part / send email and so on.
0
Comment
Question by:tolppa
  • 2
3 Comments
 
LVL 18

Expert Comment

by:ivan_vagunin
ID: 37013547
Hi! Do you mean information from contact webpart?
0
 
LVL 1

Author Comment

by:tolppa
ID: 37016156
My problem is very simple one. Basically I need to query information from current page / site. Lets say I have custom content type X with fields a, a, c. How do I query column a? How do I query Contact Person(?) field user is needed to to fill when new site is created.
0
 
LVL 18

Accepted Solution

by:
ivan_vagunin earned 2000 total points
ID: 37016436
Hi! Then I guess you want to get PublishingContact field of the current publishing page. Try this:

SPFile file = SPContext.Current.Web.GetFile(HttpContext.Current.Request.A
string pageFile = pubWeb.GetFile(.Current.Request.Url.ToString());
SPListItem pageItem = pageFile.Item;
SPField field = pageItem.Fields.GetFieldByInternalName("PublishingContact");
object objValue = pageItem[field.Id];
SPFieldUserValue contactValue = objValue != null ? new SPFieldUserValue(SPContext.Current.Web, objValue.ToString()) : null;
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question