Robert Lynch

Robert Lynch

  • NA
  • 8
  • 646

CBE Custom Action

May 4 2017 11:02 AM
Using SharePoint 2013 Enterprise.

I have an external content type that I want to add a CBE Custom Action to which will allow me
to edit the selected item in an external web app running on a different server. I want this
Custom Action to redirect me to this external web app passing the item id in the querystring
(The data source is housed in a SQL server database and the item has it's own id assigned by
SQL server).

I have gotten to the point that I can get the item id (which is assigned by SharePoint) but
what I need is the id that is assigned by SQL Server which is within the item data.

Below is what I have so far for the Custom Action and it is returning the correct SharePoint
assigned id, but I cannot figure out how to get the real item data.
 <?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="CA_SAEdit" RegistrationType="List"
RegistrationId="{5feff46d-031c-4df5-ab06-27c25edfefb1}"
ImageUrl="" Location="EditControlBlock" Sequence="1001"
Description="Edit this SA"
Title="Edit Item">
<UrlAction Url="javascript:alert('Test' + {ItemId})"/>
</CustomAction>
<CustomAction Id="CA_SADelete" RegistrationType="List"
RegistrationId="{5feff46d-031c-4df5-ab06-27c25edfefb1}"
ImageUrl="" Location="EditControlBlock" Sequence="1002"
Description="Delete this SA"
Title="Delete Item">
<UrlAction Url="javascript:

var ctx = SP.ClientContext.get_current();
var items = SP.ListOperation.Selection.getSelectedItems(ctx);
var listId = SP.ListOperation.Selection.getSelectedList();
var saList = ctx.get_web().get_lists().getById(listId);
var itemData = saList.getItemById(items[0].id);
alert('items[0].id: ' + items[0].id); <<-- This shows the correct
SharePoint id.


? ? ? WHAT IS THE BEST CODE CAN I USE HERE TO GET A VALUE FROM
WITHIN THE SELECTED ITEM ? ? ?

"/>
</CustomAction>
</Elements>
 
 If there is a better way to do this, please tell me. I am relativly new to SharePoint and
I thought this would be easy to do. But after 2 and a half days working solely on this one problem,
I still have not found a way to do it. I tried everything I could find on the internet and nothing
has worked.

Thanks in advance for any help/insight someone might provide.