Skip to main content
1-Visitor
June 27, 2016
Solved

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

  • June 27, 2016
  • 1 reply
  • 3042 views

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

    Best answer by LLawton

    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.

    1 reply

    16-Pearl
    June 27, 2016

    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.1-VisitorAuthor
    1-Visitor
    June 27, 2016

    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.

    LLawton16-PearlAnswer
    16-Pearl
    June 27, 2016

    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.