Content Model and Page Module Custom Scripts

Page Modules and Content Models have a custom scripts section under More Actions > Settings

This can be used to run custom logic. 

tab1.PNG


taba2.PNG

You can hook to on load, on before save, on after save, on before publish, and on after publishing events.

contentViewModel.CustomEvents = { 
onLoad: function (contentItem) {
//PERFORM TASKS ON ITEM LOAD
},
onBeforeSave: function (contentItem, onContinue, onCancel) {
//PERFORM TASKS BEFORE SAVE
//use the onCancel callback function to cancel the save
onContinue();
},
onAfterSave: function (contentItem, onContinue) {
//PERFORM TASKS AFTER SAVE onContinue();
},
onBeforePublish: function (contentItem, onContinue, onCancel) {
//PERFORM TASKS BEFORE PUBLISH
//use the onCancel callback function to cancel the save
onContinue();
},
onAfterPublish: function (contentItem) {
//PERFORM TASKS AFTER PUBLISH
}
};
5 out of 6 found this helpful

Comments

2 comments
  • what sorts of things can you do in these methods? is it possible to update a hidden field? some examples of how to access the content of the item would be nice, also what about accessing the content of linked items - this might be a good way to surface values several objects deep, kind of like an index for filtering through the API

    0
    Comment actions Permalink
  • Hi Richard,

    In the custom scripts you can basically do what vanilla Javascript supports for example:
    - Notify users using javascript alert and confirm
    - Pull in Agility Content using the javascript Fetch API

    ContentItem will pass you in the fields data regardless of its structure (single item, list etc.). If you need to pull additional data you can use our Javascript Fetch API.

    What it does not support is setting the value of other fields.

    0
    Comment actions Permalink

Please sign in to leave a comment.