I have a custom action where I will create a new item in the ecb menu for a document library and once clicked it will call a javascript function and there using ecma client object model I will checkout a document if the logged user is 'System account'. For other users no action is performed.

The following is the custom action and script code. This code works well in my development environment but when I deploy it in the testing environment I get

404 exception error ("Unexpected response from the server. The status code of response is '404'. The status text of response is 'Not Found')

What I found was when executeQueryAsync call is made in the script, the exception is fired. What might be the cause of this issue?

Custom Action code

   <CustomAction Description="Check out documents."
        Title="Check out items"
        RegistrationId="0x0101" >
<!--<UrlAction Url="javascript:alert('Item Id: {ItemId},\nList Id:{ListId},\nItem URL: {ItemUrl},\nSite URL:{SiteUrl}
<UrlAction Url="javascript:CheckOutItem({ItemId},'{ItemUrl}');"/>

Javascript code

 var libraryName = "Document library";

 var context = null;
 var web = null;
 var currentUser = null;
 var ItemId = null;

function CheckOutItem(itemId, itemUrl) {
try {
    ItemId = itemId;        
    context = SP.ClientContext.get_current();        
    web = context.get_web();        
    currentUser = web.get_currentUser();        
    context.executeQueryAsync(Function.createDelegate(this, this.onGetUserSucceeded), Function.createDelegate(this, this.onFailed));
catch (e) {
    alert("Error: " + e);

   function onGetUserSucceeded(sender, args) {
//alert(' Name:' + this._currentUser.get_title() + '\n Login:' + this._currentUser.get_loginName());           

function onSucceeded(sender, args) {
alert("Checked out successfully.");
window.location = window.location;

  function CheckOutItems(itemId) {
try {        
    if (currentUser.get_title() == "System Account") {
        this.list = web.get_lists().getByTitle(libraryName);
        this.item = list.getItemById(itemId);
        this.file = this.item.get_file();
        context.executeQueryAsync(Function.createDelegate(this, this.onSucceeded), Function.createDelegate(this, this.onFailed));
catch (e) {
    alert("Error: " + e);

function onFailed(sender, args) {
  • When the exception happens "The service '/_vti_bin/client.svc' does not exist." is what i got in the console in chrome. How to fix this?. Any idea? – anantharengan May 22 '13 at 12:59
  • I am closing this question as the underlying problem was the configuration rather than the specific code you are using. Instead the new question you created covers it. If you think anything here is still relevant please add it to your other question. Thanks. – SPDoctor May 29 '13 at 7:37
  • Yea correct SPDoctor. – anantharengan May 29 '13 at 7:46

The client.svc is missing in the ISAPI folder. So I copied the client.svc file from another server and placed on this server. Now the exception is not coming but I have a different exception(500 error code exception).

| improve this answer | |

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