The following example show you
how to delete a user custom action from the drop-down menu on list items.
<a onclick="deleteUserCustomAction(); " href="#">Delete Custom Action</a>
<script>
var siteUrl = '/sites/site name';
function deleteUserCustomAction() {
this.clientContext = new SP.ClientContext(siteUrl);
var oWebsite = clientContext.get_web();
this.oList = oWebsite.get_lists().getByTitle('list name');
this.collUserCustomAction = oList.get_userCustomActions();
clientContext.load(oList,'UserCustomActions','Title');
clientContext.executeQueryAsync(Function.createDelegate(this, this.deleteCustomAction), Function.createDelegate(this, this.onQueryFailed));
}
function deleteCustomAction() {
var customActionEnumerator = collUserCustomAction.getEnumerator();
while (customActionEnumerator.moveNext())
{
var oUserCustomAction = customActionEnumerator.get_current();
if (oUserCustomAction.get_title() == 'derege Custom Action')
{
oUserCustomAction.deleteObject();
clientContext.load(oUserCustomAction);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
}
}
function onQuerySucceeded() {
alert('Custom action removed');
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
related content
add user custom actions
modify user custom actions
Do you like this post?
Buy me a cup of coffe to show your appreciation!
how to delete a user custom action from the drop-down menu on list items.
<a onclick="deleteUserCustomAction(); " href="#">Delete Custom Action</a>
<script>
var siteUrl = '/sites/site name';
function deleteUserCustomAction() {
this.clientContext = new SP.ClientContext(siteUrl);
var oWebsite = clientContext.get_web();
this.oList = oWebsite.get_lists().getByTitle('list name');
this.collUserCustomAction = oList.get_userCustomActions();
clientContext.load(oList,'UserCustomActions','Title');
clientContext.executeQueryAsync(Function.createDelegate(this, this.deleteCustomAction), Function.createDelegate(this, this.onQueryFailed));
}
function deleteCustomAction() {
var customActionEnumerator = collUserCustomAction.getEnumerator();
while (customActionEnumerator.moveNext())
{
var oUserCustomAction = customActionEnumerator.get_current();
if (oUserCustomAction.get_title() == 'derege Custom Action')
{
oUserCustomAction.deleteObject();
clientContext.load(oUserCustomAction);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
}
}
function onQuerySucceeded() {
alert('Custom action removed');
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
related content
add user custom actions
modify user custom actions
No comments:
Post a Comment