Creating WorkItem from Page

Posts: 1
Joined: Mon Feb 19, 2018 2:35 pm

Creating WorkItem from Page

Postby raspe » Mon Feb 19, 2018 2:50 pm

Is there any simple way to create a WorkItem by javascript being executed when a button in a page is clicked, e.g. something like:

Code: Select all


Background: It's basically no problem to create a non-persistent WorkItem using a Velocity-script while loading a page. But because of the velocity-script being interpreted at load-time of the page, the save-call fails because during the loading-operation only read-only-operations are allowed. Now I would like to run a call which passes the escaped script to be interpreted to the Velocity-engine within the "onclick" of a button.

I don't want a user to have to use the WorkItem-perspective this time.

Posts: 80
Joined: Wed Apr 27, 2016 10:34 am
Location: Austria

Re: Creating WorkItem from Page

Postby ALMighty » Fri Mar 16, 2018 4:18 pm

I think you can do it without Javascript but solely with Velocity (Polarion uses version 1.4 of it btw) which makes it less complicated.

Instead of a button you could create a link (special ones which were designed for wikipages, see bottom of the post for more) which could execute the "escaped script" as you have called it. The link contains the URL to the same Wikipage in which you have the other, non escaped script part
+ a parameter (like for example a work item ID). In an if condition, you can then check if a parameter was passed or not. If yes, the escaped part is executed. If not (which is the inital status when you open the part), only the unescaped part is executed. I did that once at it worked fine. :wink:

Check the [url=help]detailed Syntax Help[/url] which you can find when editing Wiki Pages.
There you can find both chapters Links and Parameters which demonstrate how to define parameters and how you can inlcude them in a link, in those special links with the square brackets, hence [ ].

A code segment for loading a parameter plus an if condition that checks if the parameter has value (hence it checks if you clicked on the link) can llok like this. Note that you do not have to define the variable $request, it is more or less already "built in" like $trackerService:

Code: Select all

##get the work Item with the Input ID
#set ($parameter= "")
#set ($parameter = $request.getParameter("myParamater"))

##  Do further "un-escaped code"

## check if parameter is empty
#if($parameter == "")
  ## Do something that should not appear when the "escaped code" is executed
 ## execute the "escaped code"

You could also pack this if-condition in a method, which allows even more flexibility. :D
Playing a good game is never lame. :D

Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 9 guests