Hot answers tagged

6

Use below code to get User name: new SPFieldLookupValue(properties.ListItem["Staff Member"].ToString()).LookupValue; For User ID: new SPFieldLookupValue(properties.ListItem["Staff Member"].ToString()).LookupId;


3

Find folder name from ServerUrl of your document. It should look like "/{LibraName}/{FolderName}/{fileName.extention}" So the folder is always before the document. Coding Changes cqy.set_viewXml("<View Scope='RecursiveAll'> <ViewFields> <FieldRef Name='ID'/> <FieldRef Name='...


3

Your code looks like Server Object Model. Based on my experience on using CAML queries, I can suggest you to get rid of <Query> tags. So update your query as below Query = "<Where>" + "<Eq>" + "<FieldRef Name='ows_PostID' LookupId='TRUE'/>" + "<Value Type='Lookup'>" + ...


3

I have seen this happen before (when a programmer without SharePoint knowledge 'fixed' a problem with imported/pasted data and emptied/deleted the existing definition of DropDown values The underlying database stores anything that is written to it, so modern JSOM code can write values to a 'DropDown' field without checking those values actually match with ...


3

You can create a Custom Timer Job which will monitor the items. Just compare the current date and item modified field. For example var lastModified = (DateTime.Now - (DateTime) item["Modified"]).Days; If the duration is greater than or equal to 20 days, then take action. Steps of creating Custom Timer Job for on-premise, find here Create and Deploy Custom ...


3

Use the below code, it will give you the list of Fields that are in Display in the View and the postiion from left. public static void GetViewDetails() { ClientContext context = new ClientContext("https://testsite/test"); List list = context.Web.Lists.GetByTitle("ListName"); context.Load(list); context....


3

Single line of text can store 255 characters. So you will be good even in case of IPv6. One drawback of storing interger in text field is that you will lose the out of the box ability to apply mathematical functions like SUM etc.


3

This code should work: (web is a variable that references the web object) SPFieldUserValue value = new SPFieldUserValue(web, item["AssignedTo"].ToString()); if (value) { assignToUser = value.User; }


3

Using SPList.Items property is bad practice. Each time the property is accessed, it requests all items with all fields from database. Instead you should always use SPList.GetItems(). SPList.GetItems(params string[]) - you can use it to load only the fields that you need. As far as I remember it'll only return items in the root folder of the list. SPList....


2

Found the solution... Here's how I changed my code. private void UploadAttachments(Helper sharePointHelper, IList<HttpPostedFile> postedFileCollection, int itemId) { // Get the list SPList listToUpdate = Helper.GetList(this.BackendListName); SPListItem itemToUpdate = null; // Get the existing item to update itemToUpdate = ...


2

Open AppManifest.xml from your VS 2013 Solution and add the permissions. Please refer the below picture for the same:


2

In AppManifest.xml file add Permission for your app. If you are performing CRUD operations on List Or Library then provide necessary Permission based on scope. eg: We are using Manage Permission for developer on Site Collection Scope.


2

You'll need to look into event handlers for this. You're probably looking for the ItemUpdated event. How to create an event receiver Also MSDN ItemUpdated event


2

I've edited the complete code, to match your code. And don't forget to set permissions in the Appmanifest.xml. This should work: App.js: 'use strict' var context = SP.ClientContext.get_current(); var listItems; var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl")); var parentContext = new SP.AppContextSite(clientContext, hostweburl); ...


2

CAML schema is case-sensitive. You need to change <values> to <Values>. In general all elements are capitalized, but for some reason there are elements like <CHOICES> written in uppercase. When in doubt, best reffer to Collaborative Application Markup Language (CAML) schemas on MSDN.


2

Considering that the only times a "start date" may then change is when an item is inserted or the item preceding it is changed, I would try and see if you goal can just be achieved by using item based event handlers. An item added event could be used to retrieve the end date of the item preceding the one you are adding, and then setting the "start date" of ...


2

I think what your looking for is this: using rest var value = SP.File.get_checkOutType() https://msdn.microsoft.com/en-us/library/office/jj244900.aspx https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.checkouttype.aspx Example $.ajax({url: "/_api/web/getFileByServerRelativeUrl('" + pageUrl + "')/checkOutType", headers: {...


2

For this little requirement you do not need to create any CSOM or workflow. Just use the Alert of SharePoint. It's default feature. See the steps of alert sending here


2

You have to explicity get all fields with var fields= oList.get_fields(); ctx.load(fields) you can then loop over all with var fieldsenum = fields.getEnumerator(); while (fieldsenum.moveNext()) { var field = fieldsenum.get_current(); var fieldname = field.get_internalName(); }


2

Add $Pageitem.Update() (or .SystemUpdate()) after assigning ModerationInformation.Status: $Pageitem.Update(); You need to update the item after changing the metadata as well as after setting the Moderation Status. Your code should look like this: $Pageitem = $PagesLibrary.GetItemById($deleteditemId.Key) $Pageitem.File.CheckOut() $Pageitem["ContentTypeId"]...


2

As I stated in a very recent answer, any code running inside an elevated section must use new fresh SharePoint objects. This means you cannot use pre-created SPListItem or anything else generated from an SPSite not created under the elevated section. Here, you use properties.ListItem that was created long before your elevation. This object is not considered ...


2

Try adding web.AllowUnsafeUpdates = true; before for loop and then after for loop add web.AllowUnsafeUpdates = false; So the code will be: try { using (SPSite site = new SPSite(siteUrl)) { using (SPWeb web = site.OpenWeb()) { web.AllowUnsafeUpdates = true; ...


2

Edit form is a custom form...which is being customized not to include Description column in Edit form. How about Display form..there do u see any description field? Open the forms in Designer and create a new edit form and set it as default. you will be able to view all fields in edit form.


2

Please check the forms in SharePoint Designer and take a look which one is set to default for the edit form. If you don't have access to SPD please check the URL of the editform. The normal one is /EditForm.aspx The first steps how to customize your forms is shown here: https://afrait.com/blog/custom-new-edit-or-display-form-in-4-steps-en/


2

If both lists are same, you can use SharePoint designer workflow to copy list item from one list to other. Below link may help you to get started: http://blogs.salmanghani.info/copy-item-workflow-using-sharepoint-designer-2010/


2

Author is the person who created the item. It is assigned once the item is created and never changed. Editor is changed every time item is modified. Better use SPFieldUserValue to retrieve SPUser. foreach (SPListItem item in myItemCol) { SPFieldUserValue usrAuthor = new SPFieldUserValue(SPContext.Current.Web, item["Author"].ToString()); author = ...


2

You can check the ids from data.$1L_0 with the actual ids from your list. If they are same, then you can rely on data.$1L_0. Anyway following JSOM approach, you can flow: Add items in a array, then get ids from it using get_id(). var itemArray = []; var clientContext = SP.ClientContext.get_current(); var oList = clientContext.get_web().get_lists()....


2

Another Way You can get it using REST API. Just send a GET request to the following end point /_api/Web/Lists/GetByTitle('{list name}')/Views/GetByTitle('{view name }')/ViewFields In the response, you should get response like following { "d": { "__metadata": { "id": "Web/Lists/GetByTitle('Customers')/Views/GetByTitle('All Items')/...


2

You can try below code, using (SPSite siteCol = new SPSite("http://server/sites/Contoso")) { using (SPWeb web = siteCol.RootWeb) { SPList list = web.GetList("/sites/Contoso/Lists/Books"); SPListItem item = list.GetItemByIdSelectedFields(3, "Title", "ISBN", "Retail_x0020_Price"); String bookISBN = ...


2

Try this SPFieldUserValue userField = item.Fields["AssignedTo"] as SPFieldUser; string userName = item["AssignedTo"].ToString(); SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(userName); SPUser user = fieldValue.User; Taken from http://ethan-deng.blogspot.com/2013/03/get-spuser-from-user-column-there-are.html



Only top voted, non community-wiki answers of a minimum length are eligible