SpRestLib

SpRestLib

  • Download
  • Get Started
  • API Documentation
  • SharePoint Guides
  • GitHub

›Recent Posts

Recent Posts

  • Uploading a file to a SharePoint library using JavaScript
  • Downloading a file from SharePoint library using JavaScript and REST API
  • Converting SharePoint 2010 API column names to SharePoint 2013 API column names
  • SharePoint List Unique Permissions REST Query
  • Adding a User to SharePoint Group Using REST with SpRestLib
  • Creating SharePoint jQuery People-Picker with SpRestLib
  • Creating SharePoint List Columns Using REST
  • Uploading a file to a SharePoint library using REST

Converting SharePoint 2010 API column names to SharePoint 2013 API column names

November 3, 2018

Brent Ely

Converting SharePoint 2010 API (ListData.svc) column names to SharePoint 2013 API (_api).


Summary

The SP2010 ListData.svc REST API looks for column names in a different style than the new SP2013 _api REST API. This script will provide a mapping of old to new names, which helps a lot when converting old code!

Common column remaps are performed automatically, so ModifiedBy now becomes Editor.

For example, the "Due Date" column used in 2010 versus 2013 REST calls:

  • SP2010 API: _vti_bin/listdata.svc/Tasks?$select=DueDate
  • SP2013 API: _api/web/lists/getbytitle('Tasks')/Items/?$select=Due_x0020_Date

How To Map Column Names

Provide a list name or GUID to get a mapping for column names.

Mapping Script

var arrMap = [];
sprLib.list('Employees').cols()
.then(arrCols => {
    // A:
    arrCols.forEach(col => {
        arrMap.push({
            sp2010: col.dispName.replace(/[\W\s]/gi,'') + ( col.dataType == 'Choice' ? 'Value' : '' ),
            sp2013: col.dataName
        });
    });
    // B:
    var objMap = {};
    arrMap.forEach(item => {
        objMap[item.sp2010] = item.sp2013;
    });
    console.log( JSON.stringify(objMap,null,4) );
});

Script Results

.---------------------------------------------------------.
| SharePoint 2010 Name |      SharePoint 2013+ Name       |
|----------------------|----------------------------------|
| Active               | Active_x003f_                    |
| AppCreatedBy         | AppAuthor                        |
| AppModifiedBy        | AppEditor                        |
| Attachments          | Attachments                      |
| BadgeNumber          | Badge_x0020_Number               |
| CalcCol              | CalcCol                          |
| Comments             | Comments                         |
| ComplianceAssetId    | ComplianceAssetId                |
| ContentType          | ContentType                      |
| Created              | Created                          |
| CreatedBy            | Author                           |
| DepartmentsSupported | Departments_x0020_Supported      |
| Extension            | Extension                        |
| FolderChildCount     | FolderChildCount                 |
| HireDate             | Hire_x0020_Date                  |
| ID                   | ID                               |
| ItemChildCount       | ItemChildCount                   |
| JobGrade             | Job_x0020_Grade                  |
| Manager              | Manager                          |
| MentoredTeamMembers  | Mentored_x0020_Team_x0020_Member |
| Modified             | Modified                         |
| ModifiedBy           | Editor                           |
| Name                 | Name                             |
| Salary               | Salary                           |
| SiteLink             | Site_x0020_Link                  |
| Title                | LinkTitle                        |
| UtilizationPct       | Utilization_x0020_Pct            |
| VersionedComments    | Versioned_x0020_Comments         |
'---------------------------------------------------------'

Script Notes

  • This may not be correct 100% of the time :-)
Tweet
Recent Posts
  • Summary
  • How To Map Column Names
    • Mapping Script
    • Script Results
    • Script Notes
SpRestLib
Docs
Getting Started with SpRestLibSharePoint API ReferenceSharePoint Development GuidesAbout JavaScript Promises
Community
FacebookTwitterPinterestYouTube Channel
More
GitHub IssuesGitHub ProjectSpRestLib on Stack OverflowSite Icons
Copyright © 2019 Brent Ely