cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.

Revise Validator in Folder Browser

MN_10518175
5-Regular Member

Revise Validator in Folder Browser

We would like to disable Revise action from Folder Browser's action if certain condition doesn't matches our expectations. It can be achieved through Object's Details page, But couldn't perform the same in Folder Action. 

 

Or else, Throwing explicit exception while revising the object from Folder Browser would also be fine. Please suggest your opinion dear friends!!

16 REPLIES 16

Hi @MN_10518175 

You can write own validator and add the validator to the function in customAction.xml

There can be many validators for the function. 

 

PetrH

MN_10518175
5-Regular Member
(To:HelesicPetr)

Hello @HelesicPetr 

 

Thanks for your suggestion. The concern here is We had extended the ReviseValidator OOTB class for our custom class and chosen the selector of that specific Folder revise action, still it only calls performFullPreValidation method. 

 

On Run-time, so far, it's not possible for us to hide/block the action while revising from Folder browser.

Hi @MN_10518175 

I would suggest to create own validator not extended and configure your validator in customaction.xml

 

HelesicPetr_0-1691490798901.png

 

add your validator to the filter element

<action name="MULTIREVISEITEMS_FROMFOLDERS" checkaccess="true" enabledwhensuspended="true" renderType="PDM" selectRequired="true" uicomponent="REVISE_OUTSIDE_CHANGE">
 <command windowType="popup" class="java.lang.Object" method="MULTIREVISEITEMS_FROMFOLDERS" onClick="validateSomethingSelected(event)"/>
 <includeFilter name="disableForAdminLocked"/>
 <includeFilter name="disableForPartToCadBuildAdminLocked"/>
 <includeFilter name="myOwnValidatorRegistredInserviceproperties"/>
</action>

 

PetrH

MN_10518175
5-Regular Member
(To:HelesicPetr)

Hello @HelesicPetr ,

 

I had attempted this way as well. Since this revise action from Folder Browser had enabled/functioned through OOTB Template Processor. Our validator doesn't have privilege to hide this action at run-time, Hence looking for an alternative way to block/restrict revise action. I hope it helps you for understanding my concern. 

 

Thanks for your help !!! Kindly suggest any approach to throw explicity error/exception/alert message.

Hi @MN_10518175 

 

If I set my own validator to the revise action in folder, it works. 

So you may do something wrong. 

 

here is example of very simple validator if user is admin or not. 

 

 

 

public class AVValidator extends DefaultSimpleValidationFilter
{
	public static Logger logger = LogR.getLogger("cz.aveng.AVValidator");

	public AVValidator()
	{
	}

	public UIValidationStatus preValidateAction(UIValidationKey valKey, UIValidationCriteria criteria)
	{
		UIValidationStatus validatioNStatus = UIValidationStatus.HIDDEN;

		try
		{
			WTPrincipal realUser = SessionHelper.manager.getPrincipal();
			Vector<String> groupsList = new Vector<String>();
			try
			{
				Enumeration parentGroups = realUser.parentGroups();
				while (parentGroups.hasMoreElements())
				{
					WTPrincipalReference wtref = (WTPrincipalReference) parentGroups.nextElement();
					WTPrincipal wtAA = (WTPrincipal) wtref.getObject();
					if (wtAA instanceof WTGroup)
					{
						WTGroup workGoup = (WTGroup) wtAA;
						WTContainer groupContainer = workGoup.getContainer();
						if (container != null)
						{
							if (container.equals(groupContainer))
							{
								groupsList.add(workGoup.getName());
							}
						} else
						{
							groupsList.add(workGoup.getName());
						}
					}
				}
			} catch (WTException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			boolean isUserAdmin = groupsList.contains("Administrators");
			
			if (isUserAdmin)
			{
				validatioNStatus = UIValidationStatus.ENABLED;
			}
		} catch (WTException e)
		{
			e.printStackTrace();
		}

		if (logger.isDebugEnabled())
		{
			logger.debug(String.format("Exit AVValidator.preValidateAction()  status=%s", validatioNStatus));
		}
		return validatioNStatus;
	}
}

 

 

 

 

If I set the validator (filter) to the revise action. then the revision is shown only for administrators.

and really it works I tested now. 

 

PS: do not forget register your validator in service.properties

 

PetrH

MN_10518175
5-Regular Member
(To:HelesicPetr)

Hello @HelesicPetr ,

 

Looks Great!. Seems something different you have done in this validator. 

 

May i know what does the below lines of code did there?  I think it's a custom one. Could you please provide me the information regarding below points?

 

1.  AVUtilityNavigatorConfiguration.reloadConfigData();

 

That will be helpful for me to implement the same here.

Hi @MN_10518175 

Oh I left it there accidently. It is just my configuration loader from own properties file where is specific configuration stored.

 

Just delete the line.

 

also the GetUserGroup is my own method to get the groups of organisation

 

Vector<String> groupsList = UtilTeam.GetUserGroup((WTUser) realUser, realUser.getOrganization().getContainer());

 

PetrH

 

PS> I deleted it in the post and added the code from own method. 

@MN_10518175 

I did some corrections in the code example. 

PetrH

MN_10518175
5-Regular Member
(To:HelesicPetr)

Hello @HelesicPetr ,

 

I will try to implement the same in my windchill setup and provide the confirmation here. Kudos for your suggestions

MN_10518175
5-Regular Member
(To:HelesicPetr)

Hello @HelesicPetr ,

 

Good Day!!

 

As you suggested, I can hide the revise action from Folder browser based on Administrator logic. But the objective is to hide the revise action during run-time if user selects the WTPart from Folder and attempt to revise. Also for EPMDocument, we need to do one more attribute validations. Based on the value of attribute, need to enable/disable Revise.

 

If the condition not matches, then throwing explicit error/exception would also be good. 

MN_10518175
5-Regular Member
(To:MN_10518175)

Hello @HelesicPetr ,

 

Good Day!!!

 

Any new suggestions regarding this request. If so, Kindly provide some hints to achieve this. Thanks !!

Hello @MN_10518175 

The validator for revise action in Action menu is activated only if the page is loaded so it is not possible to use dynamic validation 

You would need to find another custom solution

 

PetrH

MN_10518175
5-Regular Member
(To:HelesicPetr)

Hello @HelesicPetr ,

 

Yes, That's right.

 

I would also looking for throwing error alert while performing revise action under certain conditions.

 

FYI, I attempted to throw exception from both validator & listener either. Look for some other approach.

Hello @HelesicPetr 

I am trying to make the validator for revisable items after click Ok.

I need to check whether all the necessary objects have been added to the table before creating a revision.

I search the way to prevent creating revisions if objects are incorrect and show user error message.

 

I writed my custom ReviseItemsTableValidator and call it on validateFormSubmission().

But this solution doesn't work.
Now I think that I need to write custom JS validation.

May be you could give advice about JS validation? 

 

 

MN_10518175
5-Regular Member
(To:IB_10495851)

Hello @IB_10495851 ,

 

As Revise wizard is functioning based on OOTB Template processor, we could not overwrite the OOTB section of this validator process and also no possible way to invoke validateFormSubmission() method here. These information is only based as per my knowledge.

 

Hello @MN_10518175 

How about javascript validations?

 

It is posible? I'm just starting to get into javascript customization in Windchill.

Announcements

Top Tags