jimminybob
jimminybob

Reputation: 1442

javascript onsave event firing from "homepage" view

I have written some javascript and attached it onto the onSave event of an entity to perform some actions when a record is deactivated. This works fine when on the form but if a user decides to deactivate the record from the entity view then this code does not get fired. Is there a way that I can attach this event to deactivating from here?

Thanks

Upvotes: 0

Views: 597

Answers (2)

Yacine Zine
Yacine Zine

Reputation: 619

You can use the a Ribbon Editor to edit the "deactivate" Ribbon Button in the homepage grid to include a javascript function in a webresource. So when it is clicked the button will trigger your javascript code.

the only adjustment you have to make is to accept an input parameter given by the ribbon button.

You just need to make a RibbonButton and set a control so that it will return all the id's of the active grid. In the link you will have the "SelectedControlSelectedItemIds" but you have more options available.

if you alter the XML of the solution. Your function will require a parameter.

function getSelectedItems(arrayOfIDS){
     for(var i = 0; i < arrayofIDS.length;i++)
     {
         //Your implementation here
     }
}

Alternatively you can choose to write a plugIn like Daryl suggests

EDIT: Ribbon Workbench: With this tool you can customize system buttons with visual ribbon button you can't.

Upvotes: 1

Daryl
Daryl

Reputation: 18895

You'll have to create plugin if you want to perform some action that doesn't take place on the actual form itself, or a button on the ribbon. See this similar question

Upvotes: 2

Related Questions