1

I have created a custom action on item list menu called Change Status as shown in the picture enter image description here

I have created this Custom Action using the following javascript code:

 function AddCustomUserActionToECB() {  
    //Get the client context,web and list object   
    var clientContext = new SP.ClientContext();  
    var oWeb = clientContext.get_web(); 
    var oList = oWeb.get_lists().getByTitle('helpdesk');
    var userCustomActionColl = oList.get_userCustomActions();  
    var oUserCustomAction = userCustomActionColl.add();  
    oUserCustomAction.set_location('EditControlBlock');  
    oUserCustomAction.set_sequence(100);  
    oUserCustomAction.set_title("Change Status"); 


     oUserCustomAction.set_url("/helpdesk/Lists/helpdesk/EditForm.aspx?ID={ItemId}"); 


        oUserCustomAction.update();          
        clientContext.load(userCustomActionColl);
        clientContext.executeQueryAsync(QuerySuccess, QueryFailure);  
    }  

    function QuerySuccess() {  
        console.log("Custom Action added to ECB menu.");  
    }  

    function QueryFailure() {  
        console.log('Request failed - ' + args.get_message());  
    } 

But I can only go to the edit mode of that item. But what I want is when we click at Change Status to automatically change the Title field to AutoGenerated. How can i do that?

1 Answer 1

0

Instead of oUserCustomAction.set_url("/helpdesk/Lists/helpdesk/EditForm.aspx?ID={ItemId}"); try to use in your code UserCustomAction.set_scriptBlock(UPDATE_ITEM_SCRIPT_TEXT). And write code to update item Title.

1
  • Do I have to call a method inside the script block or write the entire script inside UserCustomAction.set_scriptBlock( Update Code Here )? Commented Jan 11, 2018 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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