Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
7 replies Latest Post - ‏2013-06-05T08:59:12Z by wikin
wikin
wikin
41 Posts
ACCEPTED ANSWER

Pinned topic Checkbox and textfield

‏2013-05-15T09:05:35Z |

Hi,

Can anyone help me ? I created a jython script that checks the following:
if checkbox is selected and the amount in the field (mycost) is entered,
then the following should be done: (mycost + 20% ) and should displayed in the field maxcost

I have:

-two fields: mycost and maxcost (Variablen: mycost-IN Variable; maxcost-OUT Variable)

-a checkbox: mycheck (IN-Variable)

Jython Script

I have created a Script with Attributesstartpoint (Object: PURCHVIEW, Starpoint: mycost)

IF mycost IS NOT NULL

AND mycheck==TRUE

THEN   maxcost=mycost + 20%

ELSE

mycost=maxcost

My script does not work

Thanks

  • bgbaird
    bgbaird
    235 Posts
    ACCEPTED ANSWER

    Re: Checkbox and textfield

    ‏2013-05-15T14:06:58Z  in response to wikin

    Jython is very particular about indents (8 char indent ONLY) and case. I don't know if this example would work, but this would be my first crack at it.  Set logging to debug to see the print output in your log.

    Brian

    Attachments

    • wikin
      wikin
      41 Posts
      ACCEPTED ANSWER

      Re: Checkbox and textfield

      ‏2013-05-27T10:26:57Z  in response to bgbaird

      Hello,

      has perhaps anyone any idea how I can make it yet?

       

      Thank you.

  • SASHULL
    SASHULL
    275 Posts
    ACCEPTED ANSWER

    Re: Checkbox and textfield

    ‏2013-05-17T23:49:37Z  in response to wikin

    Brian is right about it being indent sensitive but the amount of characters don't matter (the only thing is that it must be consistent in the entire script, IE if one if statement is indented 4 spaces everything that needs an indent needs 4 spaces). I personally find 4 spaces the right balance to make it easy to see the indents without too many spaces.

    As for your script, null isn't valid in Jython you should instead use None like:

    if mycost is not None and mycheck==True:

    Also, there is no concept of THEN in the If Else statements (and if you need elseif it's elif). If you're getting the Java value of True you should use True (capital T and rest lowercase).

     

    My take on the script is attached (Brian's example with debugging print statements may help) but I would definitely spend time reviewing the Jython/Python language and probably review the Scripting with Maximo guide as that includes some Jython script examples.

    Attachments

    • wikin
      wikin
      41 Posts
      ACCEPTED ANSWER

      Re: Checkbox and textfield

      ‏2013-05-22T10:31:43Z  in response to SASHULL

      Thanks to all. I'll try

  • wikin
    wikin
    41 Posts
    ACCEPTED ANSWER

    Re: Checkbox and textfield

    ‏2013-05-23T08:27:06Z  in response to wikin

    Hello,
    many thanks for your Help. The script works. But I have one question. I have created this script with Attributestartpoint (Attribute: checkbox). As soon as I activate or
    disable the Checkbox - all works, but when I change the valuein the textfield(mycost) and checkbox remains unaffected, then it no longer works. How can I make it so that the script react on the changes in the text box (myfeld) and on the checkbox changes?
     

    For example, if I create a new purchase contract and:
    - Type its amount in the textbox (mycost) and the checkbox is not affected, then nothing happens, even if I save the purchase contract
    - If I change the amount in the text box (mycost), also does not happen.

    ie I always have to enable and disable the check box, so that the amount is calculated.

    Thank you very much.

    • SASHULL
      SASHULL
      275 Posts
      ACCEPTED ANSWER

      Re: Checkbox and textfield

      ‏2013-05-28T12:24:43Z  in response to wikin

      You can have more than one launch point per script, so if you need your event to fire when the checkbox is checked and when data is entered into the textbox then from the Automation Script application have a Select Action-> Create->Script With Attribute Launch Point and choose to use an existing script (down at the bottom of the very first page in the dialog there are two radio buttons, one stating New (the default selected) and one below it for Existing).

      • wikin
        wikin
        41 Posts
        ACCEPTED ANSWER

        Re: Checkbox and textfield

        ‏2013-06-05T08:59:12Z  in response to SASHULL

        Many thanks, it works.