0

I am trying to set the document ID from ScriptFunction. I tried:

workflowContext.getTarget().setId("Demo");

But it is not working

Toto
  • 89,455
  • 62
  • 89
  • 125
Anas Hosami
  • 317
  • 1
  • 2
  • 6

1 Answers1

0

You cannot set an Id of a IWorkflowObject. you may want use the IModule.move(java.lang.String newModuleFolder, java.lang.String newModuleName) function.

see sdk doc here: https://almdemo.polarion.com/polarion/sdk/doc/javadoc/com/polarion/alm/tracker/model/IModule.html#move(java.lang.String,java.lang.String)

Due to the nature of the SVN storage it may not work but breaks with a broken transaction.

I cannot test it at the moment.

Peter Parker
  • 29,093
  • 5
  • 52
  • 80
  • Thank you @peter. I think this is so beneficial. However, I tried: \n `var workitem = workflowContext.getTarget(); var moduleFolder = workitem.getModuleFolder(); workitem.move​(moduleFolder, "newName");` And it is returning : _workitem.move​ is not a function in_ Do you have any idea why. In all cases thank you for your help – Anas Hosami May 19 '21 at 16:06
  • It seems you are operating on an IWorkItem object. My comment related to the Workflow of a Document. Did you configure the workflow function for the Document or the Workitem workflow? AFAIK it is not possible to change the Id of a WorkItem. – Peter Parker May 20 '21 at 07:08
  • Sorry it was a typo. I tried it for document in workflow context. And it was giving the error workflow.move is not a function. Sorry for this. – Anas Hosami May 20 '21 at 09:08
  • you are right. you get an IWorkflowObject back which does not have the appropriate object methods. So you need to retrieve the instance of the IModule and apply the move there. You can use the var mm =workitem.getTrackerService().getModuleManager() to get the modulemanager instance but you need a ILocation object to get the IModule you need .. this is a pretty f***ed up API at this place.. – Peter Parker May 20 '21 at 13:48