cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

trigger-script is calling ambiguous java method, how can i solve this?

JensN.
13-Aquamarine

trigger-script is calling ambiguous java method, how can i solve this?

Hi @all,

now it comes (again) to light that i'm not a programmer or coder...

I want to fill a relationship-field with some entries via setRelationShipFieldValue. I have some issue-id's as a comma-seperated list (stringlist). What i've tried is to write a trigger-script like this:

var delta = bsf.lookupBean("imIssueDeltaBean");


[...]


var arr = new Array();

arr = stringlist.split(",");

delta.setRelationshipFieldValue(TargetField, arr);


What i get is this:

JavaScript Error: The choice of Java method mks.ci.server.engine.LocalTriggerManager$ScriptIssueDeltaBean.setRelationshipFieldValue matching JavaScript argument types (java.lang.String,object) is ambiguous; candidate methods are: void setRelationshipFieldValue(java.lang.String,int[]), void setRelationshipFieldValue(java.lang.String,java.lang.Object[])

How can i avoid this errormessage or how can i choose the right java-method from inside the triggerscript?

Thanks for any hint...

cheers, Jens

1 ACCEPTED SOLUTION

Accepted Solutions
LLawton
14-Alexandrite
(To:JensN.)

OK, "setRelationshipFieldValue" seems to be more finicky then usual and the doc isn't much help. It does sound like the first method you tried (pass the whole string) should work but maybe they want it formatted with the flags too.

So here's my new plan:

var arr = new Array();

arr = stringlist.split(",");

var setRels = new java.util.ArrayList();

for ( i = 0; i < arr.length; i ++ )

{

  setRels.add( parseInt( arr[ i ] ) );

}

delta.setRelationshipFieldValue( TargetField , setRels );

I hope it works.

View solution in original post

4 REPLIES 4
LLawton
14-Alexandrite
(To:JensN.)

First, you don't need to use java objects for that, you can do it all with JavaScript objects.

Second, what is "stringlist"? It's hard to tell where the problem comes from with so little context.

The split functions are different between JavaScript and java and use different arguments, java expects a regular expression.

I think you should use: var arr = new Array();

JensN.
13-Aquamarine
(To:LLawton)

Hi Laurent, thanks for your answer. I actually did use arr = new Array(), it is already corrected in the first post. stringlist is a string like this:

"264739,488754,552893,45635434,445678"

It consists of Issue-ID's and commas, thats all. First i tried to put this list directly into the relationship-field, but i got the error message, that relationship-fields cannot use such strings.

LLawton
14-Alexandrite
(To:JensN.)

OK, "setRelationshipFieldValue" seems to be more finicky then usual and the doc isn't much help. It does sound like the first method you tried (pass the whole string) should work but maybe they want it formatted with the flags too.

So here's my new plan:

var arr = new Array();

arr = stringlist.split(",");

var setRels = new java.util.ArrayList();

for ( i = 0; i < arr.length; i ++ )

{

  setRels.add( parseInt( arr[ i ] ) );

}

delta.setRelationshipFieldValue( TargetField , setRels );

I hope it works.

JensN.
13-Aquamarine
(To:LLawton)

Hi Laurent,

it works, you saved my day Thanks!

Cheers, Jens

Top Tags