Page 1 of 1

WorkItem Created or Saved

Posted: Tue Jun 09, 2015 4:05 pm
by shawn.hesch
Hello there,

I am writing a post-save script that gets the history of a work item.
When a user is creating a new work item I get an error though:
ERROR com.polarion.fme.workitemsave.actions.SaveHandler - Error in Hook-Script: javax.script.ScriptException: Wrapped com.polarion.platform.persistence.WrapperException: com.polarion.platform.persistence.UnresolvableObjectException: com.polarion.subterra.persistence.identification.UnknownObjectException: LocalId[prototype WorkItem, object PLT_TEMPLATE-123] (<Unknown source>#6) in <Unknown source> at line number 6

It is from the function I'm using to get the history of the work item.
As I said, this is only an issue if the user is creating the work item. Is there a way to tell if the work item was just created using the API?


Re: WorkItem Created or Saved

Posted: Fri Jun 19, 2015 10:23 am
by martins
Hello Shawn,

have you tried to embedd your code in a try-catch block?

Code: Select all

// Your code
} catch (e) {
I assume this should solve your problem.

Kind regards,


Re: WorkItem Created or Saved

Posted: Tue Jun 23, 2015 9:05 pm
by shawn.hesch
Hello Martin,

I ended up switching to a pre-save script but still had the issue.

I used a try catch block with some success. It works as I wish now, but I was unable to extract the error message to determine what caused the error and handle accordingly. So for now I set a string a differing values throughout the try block and handle the error depending on what the value is in the catch block.

Thanks for your answer,


Re: WorkItem Created or Saved

Posted: Wed Jun 24, 2015 12:24 pm
by fbachmann
FWIW, my Polarion instance had this kind of behaviour when the WI created was based on a template referencing an unaccessible WI (project not accessible for user/ not migrated).

I'd have a look at your WI Type configuration.

Hope this helps

Re: WorkItem Created or Saved

Posted: Thu Jun 25, 2015 8:20 am
by NickEntin

I never implemented hook-scripts myself, therefore may only speculate about problems. But couple points you may find useful:
- be careful when you parse commit message, e.g. if commit message contains "Fix for BUG-123" - it will be recognized in ALL(!) projects, which have this prefix and item BUG-123. But if you want to parse history of one of them - it will be hard to guess project ID from the message (so you'd need to extract it from the commit folder name - may be also several, etc.). It might be easier if commit messages will include project ID directly, e.g. "ProjectID/BUG-123" - this format is also supported by Polarion for unique identification of work item in particular project (won't be anymore linked to all work items in projects, which have BUG-123, but only project with ID ProjectID).
- be sure that your hook has appropriate credentials (user), which have access to the work items in particular projects. This user is not the same user, who does commit.

Best regards,

Re: WorkItem Created or Saved

Posted: Mon Jun 29, 2015 11:24 am
by martins
Hello Shawn,

The problem is the internal object handling of Polarion. Before a WI is saved for the first time the pre- / post-save scripts operate on a "temporary" object. On this temporary object some functions don't work correctly. When you edit an existing WI the pre- / post-save scripts operate directly on this WI-object and everything works fine.

We are NOT talking about SVN hook scripts in this topic but about scripts you can implement with extension ... -item-save

Kind regards