Hello @Developers! Conversation in the <#811676497965613117> room raised attention of an issue with preCreate hooks which needed to be corrected. This is an unfortunate, last-minute breaking change. The preCreate hook for Documents in 0.8.3 was incorrectly receiving the fully expanded DocumentData rather than the expected initial data object (usually just a name and a type, though folder can also be included). What does this mean With the prior version of the preCreate(Document) Hook, this was a functional example:
//working in 0.8.0-0.8.3
Hooks.on("preCreateActor", (actor, data, options, userId) => {
data.name = "Some Different Name";
data.items = [{name: "Sword", type: "weapon"}, {name: "Shield", type: "equipment"}];
});
//working in 0.8.0-0.8.3
Hooks.on("preCreateActor", (actor, data, options, userId) => {
data.name = "Some Different Name";
data.items = [{name: "Sword", type: "weapon"}, {name: "Shield", type: "equipment"}];
});
After this change, you will need to wrap your changes in an update call:
//working after 0.8.4
Hooks.on("preCreateActor", (actor, data, options, userId) => {
actor.data.update({
name: "Some Different Name",
items: [{name: "Sword", type: "weapon"}, {name: "Shield", type: "equipment"}]
});
});
//working after 0.8.4
Hooks.on("preCreateActor", (actor, data, options, userId) => {
actor.data.update({
name: "Some Different Name",
items: [{name: "Sword", type: "weapon"}, {name: "Shield", type: "equipment"}]
});
});
We're sorry this wasn't caught in alpha testing, but this change is necessary as the implications of this are far-reaching. I know that this may catch some of you who have already updated for 0.8.x unawares and may require you to implement changes, but hopefully the change is incredibly trivial to make. The full details of this are outlined here: https://gitlab.com/foundrynet/foundryvtt/-/issues/5126 If you have any questions regarding this or other update issues, we are glad to assist in #08x-dev-support
GitLab
The preCreate{DocumentName} hook was incorrectly being provided wit...
The intended design of the _preCreate{DocumentName} hook is to provide the hooked function with the following arguments:
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?