Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Dears,
I have created a new subtype of change notice and a subtype of change task, when I create a new change notice for a part I need to define the change task, for this change task I am using my own defined subtype, when clicking on the completion of this task I need to use the I need to use a custom Form Delegate to check the lifecycle state of the resulting object when clicking on the completion of the task, I've already implemented it, but this customized function will affect all the change tasks, so is it possible to define the Form Delegate only for a specific subtype? Thank you!
Solved! Go to Solution.
I think type checking is an easier way of validating and shouldn't be much of a burden. Another approach is to add supportedTypes tag in action.xml, from where the custom delegate code is being called.
<supportedTypes>
<type value="WCTYPE|wt.change2.WTChangeActivity2|<custom_subtype>"/>
</supportedTypes>
However, in this case, we might still need to handle out-of-the-box (OOTB) cases with an 'if-else' statement in the code. Give it a try and see if it helps.
Inside your custom form delegate code, you can fetch a List<ObjectBean>, traverse through them, and check if the ObjectBean's type is of WTChangeActivity2. If it is, you can then further check if it is of your custom subtype using TypeIdentifierUtility.
WTChangeActivity2 ca = (WTChangeActivity2) objectBean.getObject();
//if ca is instance of custom_subtype
//if true then procced with business logic for checking the lifecycle state of the wtobject
pseudo code: (Check ptc articles for more examples)
String typeIdentifier = TypeIdentifierUtility.getTypeIdentifier(ca).getTypename();
if ("custom_subtype".equals(typeIdentifier))
@ANNA_02 Thanks for your reply, This is accomplishing the goal, but I have another concern, this function will still work globally, we are just filtering the corresponding subtypes in the code, as the global will call this code every time the finish button is clicked, will this be a burden on the system? Going back to this original requirement, is there a better way to verify the lifecycle state of the Resulting object when I create a Task? Thank you.
I think type checking is an easier way of validating and shouldn't be much of a burden. Another approach is to add supportedTypes tag in action.xml, from where the custom delegate code is being called.
<supportedTypes>
<type value="WCTYPE|wt.change2.WTChangeActivity2|<custom_subtype>"/>
</supportedTypes>
However, in this case, we might still need to handle out-of-the-box (OOTB) cases with an 'if-else' statement in the code. Give it a try and see if it helps.