Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Submitting a document to approval workflow automatically

Hi Gurus,

I want to submit a XML form directly for approval without anyone

going to submit for approval.

I have gone thru the forums, have conjured that a repository service needs to be written.

i wrote that, this is the code.

protected void addRepositoryAssignment(IRepositoryManager mgr) throws ServiceNotAvailableException {
    // Implement this method: Usually the service registers itself for certain events at the repository manager.
	try{
		 mgr.getEventBroker().register(this, new ResourceEvent(ResourceEvent.CREATE_CHILD, null));
	 }catch(WcmException e){
	 }





 public void received(IEvent event) {
	IResource resource = (IResource)event.getParameter();
	
		try{			
		//	get the statemanagement service from the resource
					   IRepositoryServiceFactory factory = ResourceFactory.getInstance().getServiceFactory();
					   IStatemanagementManager statemanagement =
					   (IStatemanagementManager)factory.getRepositoryService(resource, IWcmConst.STATEMANAGEMENT_SERVICE);

					   IStatemanagementResource sResource =
					   statemanagement.getStatemangementResource(resource);


					   IResourceTransition transition = sResource.getTransition("lbl.submit");
//						 if everything is correct than transition is not null
					   if (transition != null) 
					   
					  
					   {transition.execute(); 
						
					
					   }
		}catch(Exception e){
			e.printStackTrace();
		}

These are the following issues coming up.

1)

I have deployed and activated this service for the required repository.

When i restart the server there is no efffect, if i create a document it still gets created in "in progress" status.

But i can manually start the approval process.

I have already got one sample service running which renames all the files created.

I am on EP 7.0 SPS 16

2)

One more issue i noticed is that if i deploy the service and i dont restart the server I am unable to start the approval process even manually.

It throws me an error like

Could not execute command 'com.sapportals.wcm.rendering.uicommand.cm.UIStatemanagementCommand'

Could anyone please throw some light as to why this is happening or why the service isnt working, since everywhere on the forums i saw this is the code which is functional.

Any help would be appreciated.

Thanks and Regards,

Nikhil

Former Member
Not what you were looking for? View more on this topic or Ask a question