Get UniqueId of a list item from SPMetal code - sharepoint

Quick question. I want to generate code with SPMetal that includes the UniqueId field (the field that has the GUID for the list item), but somehow in Visual Studio I end up with either:
A list without that field
A list that in theory has that field (UniqueIdUniqueId.. why is it named that way?), but when I try to run it, throws me a NullException.
I'm using Sharepoint 2010, VS 2010.
Can you point me in the right direction? I'm stalled right now. I would paste you the XML file I've been using as parameters to SPMetal, but my servers are down right now. I'll post it ASAP, but if anyone has the answer on how to generate a class that includes that particular field, I'd be thankful.
Thanks!

The solution was: use the "GUID" hidden field. Duh.

I think is no way to include 'UniqueId', because is not a part of any content type.
If this realy need to get 'UniqueId', try write SQuery, which get item by ID with one viewField (to maximize performance).

Related

NetSuite sublist

I am having a problem finding out an id of a sublist. I am using SuiteScript 1.0. For instance, I need to list the components of an assembly item record, how do I find out the list id and the "type and field name to use in the nlapiGetCurrentLineItemValue or nlapiGetCurrentLineItemValue methods. What I am looking for is how now and in the future when presented with a sublist, do I go about finding the ids of the objects needed. I have internal ids turned on but that does not help in the sublist view. What is the best way to get this information when I need it? thanks for any help you may give.
You can use nlapiGetAllLineItems() to get an array of all the sublists. You may need to load the record first and do record.getAllLineItems()
I have found the most useful method for figuring out internalids is to run nlapiLoadRecord(..) in your Browser Console and examine the resulting object. Another trick is the add &xml=T to the end of the URL of the record, which displays the record in XML format. NetSuite also documents most of the internalids in the Records Browser.
In this case you use console in Google Chrome. Open the Specific Assembly Item Record page and Press F12 and select console.After give following code
nlapiLoadRecord('assemblyitem', 90088(id for specific record));
after show result in console. Select linefields and Item. Now it show the fields of sublist. If You have any doubt let me know.

Kentico cms.file publish date

I've got a simple repeater that list links to uploaded documents using cms.file. I'm drawing a blank on adjust the ORDER BY based on publish date. I can't find anything here on this, so i apologize if this is a duplicate.
Best practice is to add custom field to page type (in this case cms.file or better create the new one) and set ORDER BY condition to this new field. There are also properties like DocumentModifiedWhen, DocumentCreatedWhen, DocumentCheckedOutWhen you can use.
I'm going to use DocumentModifiedWhen as the ORDER By statement.
There are two fields [DocumentPublishTo] and [DocumentPublishFrom] that you can think of using. These are the two fields which appear at the bottom of each form page by default.

List EditForm in MS Sharepoint not getting correct Item

I have made a new custom EditForm.aspx in MS sharepoint on one of my lists, but when I try to edit an item, it gets the first item in the list, and not the one im trying to edit.
I have tried reverting to the old form, but it still keeps doing it.
I am quite new to Sharepoint and don't quite understand how the parameters are being passed, perhaps the error could be there somewhere?
Is the section where the sources are defined?
It is rather urgent so any tips would be much appreciated. I haven't found any solution online yet.
I couldn't find the mistake, as the Edit Item button seemed to generate the incorrect ID for some unexplainable reason.
My fix was to create a new empty list, then create a new EditForm and ViewForm from the new forms, delete the webpart, Insert->Sharepoint Controls->Custom List Form. I selected the old (broken) list form type.
I then copied this code over to the old list viewForm and EditForm and it worked as it did normally.
ID item of item to be edited is passed to edit form in the query string like this:
editform.aspx?ID=ItemId. So, first, check if ID is in the url and correct.

SharePoint 2010 multiple users accessing same list issue

We have a list with 1000+ phone numbers in it. This list is sorted in a specific order by due dates and other criteria. This order is very important and needs to be maintained in the solution.
We have a group of callers (roughly 4) that will be calling the numbers in this list in the order they are sorted by. These callers are to be presented with one list item at a time, via an InfoPath form, and once they make the call they will update the list item and be presented with the next list item dictated by the sort order.
Here's the problem: This would be very easy with 1 caller but with 4 callers we don't want them calling the same people more than once. So they need grab the next list item off the top of the pile that isn't already taken by another caller.
Is there a way to build a webpart (remember without Visual Studio unfortunately) that as soon as it loads would find the first list item that is unassigned and assign it to the current user?
We could accomplish this whole thing manually of course by having an admin assign all the calls each day with a large copy/paste in Datasheet View but automatic would be soooo much better.
I will mention that I DO NOT have Visual Studio so I don't have that as an option here. But I do have SharePoint 2010, SharePoint Designer 2010, and InfoPath 2010.
I hope this makes sense and any ideas, thoughts, approaches would be greatly appreciated since I've run out! Thanks!!!!!
You can develop SharePoint web parts using Visual Studio Express, but its a bit harder as you miss some of the tools that make your life easier like WSPBuilder etc.
SO - Building webparts with Visual Studio 2010 Express
Another alternative would be to use javascript client side to access SharePoints Web Services via SPService - then nothing more than notepad is required.
You're really using a wrench as a hammer with either of these approaches though, so I've got to say - how much do you value your time at? ;)
I can offer a very bodgy alternative; presuming all the items are added piecemeal (not in the same second). You could add a calculated column to assign each item at random on addition, using the following formula:
CHOOSE(MOD(SECOND([Created]),4)+1,"Operator1","Operator2","Operator3","Operator4")
I suggest a workflow that is assigned to listItem's edit; that when a caller edits its extra field like "Operating(bool)" after the calling workflow completes; the item is disabled somehow.
Only overhead of this is a caller needs to edit the item every time.
But the easy part is a listviewer webpart (oob) can be used just with a default view setting like "Operating" field is "false" only.
This is simple. On form load, instruct the form to update a status field to (let's say 'assigned') and automatically resubmit the form back. Your infopath list that pulls in the next number to call would need to exclude any that are in the assigned status. You'd also need to re-query your data connection to refresh the list each time before a call is made to grab the next available. Once the caller is finished, they can click a button that submits the form, clears the status field and closes the form.
Yo can also pull in the active items into an infopath form using a secondary data connection. There is a way to use the insert hyperlink into the form field, and make any of your fields a URL hyperlink directly to the individual item. Although you'd have to have the URL epsaved in a field in the form the item was created in. That's easy to do, you can just con at the URL with the form name.

SharePoint Custom Fields In List View

I've got a requirement to hold a DateTime value in a SharePoint field but to customise the display in a list view so that it shows as a mmmm string. The underlying value must remain as the DateTime so the sort is chronological rather than alphabetical.
So I think that a Custom Field is the way to go, I'll also get some added benefit in restricting the user interface to a month picker so even if there is another solution I'll likely go down this route to get that.
I've read that I can apply custom templates to the new, edit and display actions but I can't seem to find anything saying how to alter the list view (display patterns doesn't seem to be enough).
Anyone got any ideas?
Thanks
Justin
I dont know if this is what you are looking for but I have used a solution with a custom fieldcontrol that overrides RenderFieldForDisplay like:
protected override void RenderFieldForDisplay(HtmlTextWriter output)
This is a similar post:
How to manage column based access control in Sharepoint lists?
Ended up using a bit of an ugly series of <IfSubString> within the RenderPattern...

Resources