Skip to main content
12-Amethyst
May 14, 2024
Solved

Is it possible to set/update the modified by attribute on the object with out iterating using api?

  • May 14, 2024
  • 2 replies
  • 2283 views
SessionHelper.manager.setPrincipal(strModifier);
		
		System.out.println("Current session user :- " + SessionHelper.manager.getPrincipal().getName());
		
		
		//check out part
		epmDocument = (EPMDocument) WorkInProgressHelper.service.checkout(epmDocument,WorkInProgressHelper.service.getCheckoutFolder(),"").getWorkingCopy();
		
		WTUser modifer = OrganizationServicesHelper.manager.getAuthenticatedUser(strModifier);
		VersionControlHelper.setIterationModifier((Iterated)epmDocument, WTPrincipalReference.newWTPrincipalReference(modifer));
 
		//check in part
		WorkInProgressHelper.service.checkin(epmDocument ,"checkedin");

So A.1 is before the change of "modified by" and A.2 is after the "modified by".

I changed the modified by using api by  doing checked in+ checked out simultaneously.

Above is a snippet of the code i used:

 

 

Best answer by avillanueva

WorkInProgressHelper will certainly iterate. Have you tried just using PersistenceHelper, making the modification and saving? 

2 replies

avillanueva
23-Emerald I
23-Emerald I
May 14, 2024

WorkInProgressHelper will certainly iterate. Have you tried just using PersistenceHelper, making the modification and saving? 

12-Amethyst
May 14, 2024

can you give the syntax according to persistanceHelper?

avillanueva
23-Emerald I
23-Emerald I
May 14, 2024

https://www.ptc.com/en/support/article/CS197332?source=search

This is a bit out of date but should get you started. 

18-Opal
June 3, 2024

FYI, It is possible to modify the value of any attribute including modified by using APIs without iterating the object.

In fact, if a company requests code to make changes to existing values or even add new attributes or even new links, maybe they are requesting to replace Calculated links with Content links or whatever, I always ask if they want the object iterated or not.