Hot answers tagged

9

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;


6

Make sure that the column you include in the where clause is defined as an indexed column in SharePoint. You can check by going to the list you're querying and into List -> Settings -> Indexed Columns. It's not applicable in your CAML query, but if you have more than one 'where', ensuring the first where hits an indexed column can increase efficiency. ...


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


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

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


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

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

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

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

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

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


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

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

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

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

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

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

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/


1

It is not possible to have cascading dropdowns (behavior that you are describing) in OOTB SharePoint forms. There are third party solutions (both farm solution and add-ons) that add this functionality to lists. You can also have a look at SPServices jquery library and add this functionality yourself to the form. This does require some javascript development ...


1

A little more background, AddItem() is the preferred method because as the list gets larger, it has to download all the items in the list when you call list.items.add() in order to add the one item. This is why MS created the AddItem() call so that you could add an item without doing a query of all items in the list. Avoid calling .Items off of a SPList ...


1

You can find all the settings you can pass to SP.UI.ModalDialog here Unfortunately, you can't open the dialog without "cancel" button in it. What you can do is to edit NewForm.aspx page. Go to your list/library Click "new", this will redirect you to NewForm.aspx Edit Page Add Content Editor Web Part somewhere above your form Add the following css to your ...


1

Once you intance the item, loop within attachments collection. Sample code: SPAttachmentCollection attachments = listItem.Attachments; foreach (string attachment in attachments) { string t = SPUrlUtility.CombineUrl(listItem.Attachments.UrlPrefix, attachment ); } Source: SurPoint


1

Keep in mind that bit of code might be slow depending on the size of the list: foreach (SPListItem listItem in list.Items) { var attachmentURLs = GetAttachmentUrls(listItem) } private IEnumerable<string> GetAttachmentUrls(SPListItem item) { return from string fileName in item.Attachments orderby fileName select ...



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