Create link, addLinekdItem function

Description
Harou33
Posts: 10
Joined: Wed Apr 04, 2018 10:40 am

Create link, addLinekdItem function

Postby Harou33 » Tue Jun 05, 2018 9:07 am

Hello,

I write a script, which should create a new link between two existing items.
I have something like that (only small part of scipt):

Code: Select all

#set($item_link_derived1 = $link_derived.getLinkedItem())   
  #set($item_link_derived2 = $sys_reused.getLinkedItem())   
   
       #set($createLink = $item_link_derived1.addLinkedItem($item_link_derived1.getUri(), $item_link_derived2.getUri(), $item_link_derived1.getProject().getWorkItemLinkRoleEnum().wrapOption("satisfies"), null, true))   
       
    $item_link_derived1.save()
    $transactionService.commitTx()



And my question is: Do I use addLinekdItem function properly? Where is error in my script because it doesn't create a link.

Thank you

PatrickClaus
Posts: 8
Joined: Thu Jan 18, 2018 11:02 am
Location: Frauenauracher Str. 85, 91056 Erlangen

Re: Create link, addLinekdItem function

Postby PatrickClaus » Thu Jun 07, 2018 12:02 pm

Two suggestions:

- Check your addLinkeditem Method. See the API DOC:
https://almdemo.polarion.com/polarion/sdk/doc/javadoc/com/polarion/alm/tracker/model/IWorkItem.html#addLinkedItem-com.polarion.alm.tracker.model.IWorkItem-com.polarion.alm.tracker.model.ILinkRoleOpt-java.lang.String-boolean-

The method takes 4 arguments, but I think you are giving it 5. It does only require the target workitem for which the link needs to be created.

- Try wrapping your save() method and the commitTx() into a beginTx() and endTx(). See here: https://almdemo.polarion.com/polarion/sdk/doc/javadoc/com/polarion/platform/ITransactionService.html
It has helped me in the past, when transactions were not saving to the live Polarion system.

I am not sure, but I hope this will help.
Best Regards,
Patrick Claus

External service provider at Valeo Siemens eAutomotive GmbH
Frauenauracher Str. 85
91056 Erlangen, Germany
Mail Address

Harou33
Posts: 10
Joined: Wed Apr 04, 2018 10:40 am

Re: Create link, addLinekdItem function

Postby Harou33 » Thu Jun 07, 2018 1:11 pm

You are right! It's working now, thank you very much!


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: Bing [Bot] and 5 guests