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?

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.

  • Do I have to call a method inside the script block or write the entire script inside UserCustomAction.set_scriptBlock( Update Code Here )? – Nderon Hyseni Jan 11 '18 at 10:48

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.