Skip to main content
avillanueva
23-Emerald I
23-Emerald I
April 11, 2023
Solved

Adding my own afterVK Validator for Change Task set attributes page

  • April 11, 2023
  • 2 replies
  • 5562 views

I would like to add my own validation logic to creating and editing a change task, specifically the set attributes page. I see in the JSP for create its using the default for "object":

<jca:wizardStep action="defineItemAttributesWizStep" type="object"/>

and that already has a afterVK validator:

 

<objecttype name="object" class="wt.fc.Persistable" >
 <action resourceBundle="com.ptc.core.ui.componentRB" name="defineItemAttributesWizStep" id="defineItemAttributesWizStep" afterVK="setAttributesWizStep" preloadWizardPage="false" required="true" >
 <component name="defineItemAttributesWizStep" typeBased="true" windowType="wizard_step"/>
 </action>
</objecttype>

 

I do not want to upset and OOTB logic defined in the setAttributesWizStep and I only want this to be run for change task, not all objects. Is there an easy way to hook in this check?

Would I need to break from the default call out for "object" in the create.jsp and change the objectHandle to "task" and the copy the definition with my mod?

 

 

Best answer by BjoernRueegg

Also an easy way to do this would be to override the FormProcessor. So you don't need to add your own action-model an actions. In the form Processor you can use the preProcess method to check the logic in the form. Just another way to do it.

2 replies

18-Opal
April 11, 2023

@avillanueva 

Can’t you add your own custom data utility that gets fired when the user selects the “Finish” button.

I think typically an OOTB data utility gets fired when you hit Finish and a validator can be fired when you hit the Next button.

 

So, you should be able to pick when you want your “validation” code to be fired.

 

I’ve not done this with Change Task but I have with Promotion Request. I would think it should work pretty much the same.

 

Just curious, but what are you validating? The object’s in the task are not already on an active CN/CA?

avillanueva
23-Emerald I
23-Emerald I
April 11, 2023

I am validating that the user did not pick the same person (themselves) for assignee and reviewer. Lots of ways to accomplish this I know but since jsp was defined to "object" and it traces back to SetAttributesStepValidator, I want to leave that as is but add something special to Change Task only. I think I know what I need to do. I will try extended that class and add my logic. Just means I need to alter create and edit jsp file to remove "object" clause to be more specific.

18-Opal
April 11, 2023

@avillanueva 

That was one of the things I was validating with the Promotion Notice.

Had to validate that a couple of roles had principals (if principal was group the group has WTUsers).

Had to validate the creator was not specifying themself as an Approver or Reviewer. (Nice try Joe User, but we’re not going let you slip your work by without some else looking at it).

Also, had to validate that the objects were not already on an active Promotion Request.

17-Peridot
April 17, 2023

Also an easy way to do this would be to override the FormProcessor. So you don't need to add your own action-model an actions. In the form Processor you can use the preProcess method to check the logic in the form. Just another way to do it.

avillanueva
23-Emerald I
23-Emerald I
April 17, 2023

I might have to do this. All my tests have failed to show any execution of my validator specified in the afterVK block. I will do a quick stupid check before trying something new.

HelesicPetr
22-Sapphire II
22-Sapphire II
April 17, 2023

Hi @avillanueva 

Have you read this? https://www.ptc.com/en/support/article/CS171922

if I understand correctly the afterVK is activated by next|previose buttons 

PetrH