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 ...


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

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

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

Explanation Based on your affirmative response to my comment, I've gone ahead and wrote this using the JSOM API. The script works by disabling the ReadOnly property on the RichMessage field, updating the values on your target item, and re-enabling the ReadOnly field. Up until now, this is the only working strategy I've found to change read-only fields from ...


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

As you are hitting the server to frequently to Add items, SharePoint sometimes do stop the execution in between. I faced the similar issue when i was deleting items from the list. Your code is fine, I would suggest you to add a few moments of delay after adding like 50/100 items. Its even better if you can do an asynchronous loop but it will require you to ...


2

Rupesh, You need to use ProcessBatchData for your scenario if you can use server side code. If you want to use only CSOM the below code works just fine. I have tested it already $(document).ready(function() { ExecuteOrDelayUntilScriptLoaded(abc, "sp.js"); }); function abc() { context = new ...


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

Avoid using SPContext inside receiver. SPContext doesn't exist in a feature receiver. Instead use the Properties object as it includes a reference to the site or web use following public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = properties.Feature.Parent as SPWeb; using (SPSite site = new ...


2

Because you do not Change the value in the field, you just Change the value in your variable. you have to item[fieldID] = "";


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

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

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

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() ...


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 = ...


1

You are confusing your list item ID values which are 1-based integers with the SPListItemCollection index which are 0-based integers. If you examine the output of the MSDN sample code here: SPListItem.ID property you will see SPListItemCollection index doesn't match the list item ID. In addition, if you look here: SPListItemCollection.Item property ...


1

You can create an SP designer workflow for sending email. You need to activate the workflow on update event only.


1

Thanks Eric Alexander as I have figured it out with some direction from you. I have found also that by changing this line: "Item Name" = $item.File.Name To: "Item Name" = $item.Name That it returns both list names and file names from Doc Libraries as well. I tried what you posted but some Item Names returned blank. Not sure of what the reason was.


1

you can find the updated fields by comparing the actual version fields with the version fields before. Example code can be found here: http://charliedigital.com/2011/03/04/getting-version-changes-from-sharepoint/ Keep also a view on fields which are null and which contains equal strings. Hence I changed the foreach loop like this: foreach (SPField field in ...


1

This is the code generated by the tool that @Atish commented. Note the "at" SPList list = web.Lists[new Guid("d4dd7678-6dd9-47de-9d0c-951368081bdf")]; var q = new SPQuery() { Query = @"<Where><Eq><FieldRef Name='PostID' /><Value Type='Lookup'>3</Value></Eq></Where>" }; var r = list.GetItems(q);



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