Skip to content

Instantly share code, notes, and snippets.

@avasyukov
Last active August 29, 2015 14:03
Show Gist options
  • Save avasyukov/6f58da842b45930d3afd to your computer and use it in GitHub Desktop.
Save avasyukov/6f58da842b45930d3afd to your computer and use it in GitHub Desktop.
// Custom action implementation
MyCustomAction = function(item)
{
// The property we are going to set
var targetProp = "prop_alvexdt_signingDate";
// Current date converted into ISO8601 format
var now = Alfresco.util.toISO8601(new Date());
// Form processor URL for current item
var formprocessorURL = Alfresco.constants.PROXY_URI + "api/node/" + Alfresco.util.NodeRef(item.nodeRef).uri + "/formprocessor";
// Create request body
var postBody = {};
postBody[targetProp] = now;
// Send request to our url with our data - change property of the item
Alfresco.util.Ajax.jsonPost(
{
url: formprocessorURL,
dataObj: postBody,
// Success callback is called after the item is changed
successCallback:
{
fn: function(resp)
{
// Set local (in-browser) item properties
item.itemData[targetProp] = {};
item.itemData[targetProp].value = item.itemData[targetProp].displayValue = now;
// Inform datagrid that the item was changed and should be re-rendered
YAHOO.Bubbling.fire("dataItemUpdated",
{
item: item
});
},
scope: this
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment