Set dispositions to "N/A" on all affected documents with action set to "Revise"
- 6 years ago
Hello,
Ah. This is an Affected Item. Affected Items are pretty unique in terms of their data model. It'll likely take a little more work to get the ItemType of the affected item you've selected.
The first step is to establish what data you have access to inside of this in your server event. You can check this a few ways either by turning on logs or by debugging into the method. this is going to store the request that's being sent to the server to add your affected item. As an example, let's work under the assumption that you're only given the bare minimum of information.
<Item type="Affected Item" action="add">
<action>Revise</action>
<affected_id keyed_name="My Document">BC5157C0BB844887817719973C32C5AD</affected_id>
</Item>From this request, we don't know what the ItemType of the affected item is; we just know the ID. To work around this, we can do a query to see if there's a Document in the system that has this ID. If we get a result, we know that the affected item is a Document and we should set the default values for the properties. If we get back nothing, the affected item is not a Document, and we should not set the default values for those properties.
Innovator inn = this.getInnovator();
Item affectedDocument = inn.newItem("Document", "get");
affectedDocument.setID(this.getProperty("affected_id"));
affectedDocument = affectedDocument.apply();
if (affectedDocument.isEmpty())
{
// The affected item is a Document
}
else
{
// The affected item is not a Document
}Chris