WorkItem Created or Saved

Description
shawn.hesch
Posts: 5
Joined: Thu Jun 04, 2015 2:12 pm

WorkItem Created or Saved

Postby shawn.hesch » Tue Jun 09, 2015 4:05 pm

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: sun.org.mozilla.javascript.internal.WrappedException: 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?

Thanks,
Shawn

martins
Posts: 181
Joined: Thu Nov 05, 2009 3:24 pm

Re: WorkItem Created or Saved

Postby martins » Fri Jun 19, 2015 10:23 am

Hello Shawn,

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

Code: Select all

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

Kind regards,

Martin

shawn.hesch
Posts: 5
Joined: Thu Jun 04, 2015 2:12 pm

Re: WorkItem Created or Saved

Postby shawn.hesch » Tue Jun 23, 2015 9:05 pm

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,

Shawn

fbachmann
Posts: 49
Joined: Thu Apr 24, 2014 12:10 pm

Re: WorkItem Created or Saved

Postby fbachmann » Wed Jun 24, 2015 12:24 pm

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
François

NickEntin
Posts: 472
Joined: Tue Oct 24, 2006 10:27 am
Location: Polarion Software GmbH, Stuttgart
Contact:

Re: WorkItem Created or Saved

Postby NickEntin » Thu Jun 25, 2015 8:20 am

Hi,

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,
Nick

martins
Posts: 181
Joined: Thu Nov 05, 2009 3:24 pm

Re: WorkItem Created or Saved

Postby martins » Mon Jun 29, 2015 11:24 am

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.

@Nick:
We are NOT talking about SVN hook scripts in this topic but about scripts you can implement with extension http://extensions.polarion.com/extensio ... -item-save

Kind regards

Martin


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: Google [Bot] and 12 guests