0

I want to list down all the fields which are present in SPList in the Display form.

Also I want to know the display order for the fields.

How can I get this information?

In further detail... I have write the custom services for my mobile application with the server side CSOM object. I wanted to show the List item with the details as same as the SharePoint display form shows.

I am able to get the all fields from the list but wanted show the fields which actual present in display form is same order.

For that how can i get the fields

  • Hi! Your question will get more attention if you tag it with the SharePoint version in question (2010, 2013 etc). :) – Robert Lindgren Nov 25 '13 at 10:49
  • @RobertLindgren - weren't we supposed to use the version tags only when the question is specific to a SharePoint version? don't feel it is the case. – BlueSoul Dec 17 '13 at 13:04
  • I have no idea if the question is targeted to a version or not, but when it comes to webservices, and CSOM, these API:s differ quite a lot between the different versions (especially what can be done, and what can't). :) – Robert Lindgren Dec 17 '13 at 13:07
1

You must use SPFieldLink class to get the order of fields in content type see the link. To get all fields from Display form you need get all fields from content type that not hidden.

var contentTypeCollection;
  var contentType;
  var fieldLinks;

  function getFieldLinks() {
  var clientContext = new SP.ClientContext.get_current();
  if (clientContext != undefined && clientContext != null) {
  var web = clientContext.get_web();
  this.contentTypeCollection = web.get_contentTypes();
  this.contentType = contentTypeCollection.getById("0x01001EE585131CF22F448BB03959CA66EB11");
  this.fieldLinks = this.contentType.get_fieldLinks();
  clientContext.load(this.fieldLinks);
  clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
  }
  }

  function onQuerySucceeded() {
  var fieldLink = "Field Links :\n ";
  var fieldLinksEnumerator = this.fieldLinks.getEnumerator();
  while (fieldLinksEnumerator.moveNext()) {
  var link = fieldLinksEnumerator.get_current();
  fieldLink += link.get_name() + '\n';
  }
  alert(fieldLink);
  }
| improve this answer | |
  • Can you please let me know any CSOM example for the same.... – Optimus Nov 25 '13 at 10:23
  • In further detail... I have write the custome services for my mobile application with the serverside CSOM object. I wanted to show the List item with the details as same as the sharepoint display form shows. I am able to get the all fields from the list but wanted show the fields which actual presnt in diplay form is same order. For that how can i get the fields – Optimus Nov 25 '13 at 11:27
0

You can use PowerShell to get a list of fields and show if they are hidden

Code below loops through the contenttypes in a list and show if the field is shown in a display form. The order of the FieldLinks collections is the display order in the forms.

$url = "<url of site here>
$listName = "<name of the list here>
$web = Get-SPWeb $url
$list = $web.Lists.TryGetList($listName)
$list.ContentTypes | % { $_.FieldLinks } | select Name, Hidden
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.