0
Hello,

I have a multi-relational field that I'm displaying as checkboxes.

If I select 2 out of 4 in a transition only those two will display on the State form.

If I use another transition to update the field all four checkboxes will show. I only want the two that are selected to show similar to the way its displaying on the state form.

Is there some javascript that will enable me to do this?

Regards,

Will

Accepted Answer

Friday, October 27 2017, 11:37 AM - #Permalink
0
Will,

See if this helps.

1. In the form properties in Composer on the Javascript tab make sure the JQuery box is checked.
2. Try this line instead from the original code.
$(":[value='"+ x[i].value +"']").hide();

In troubleshooting just use this code and see what the alert says

var x = $(GetFieldWidgetByName("PENDING_LOWER_ENVIRONMENTS")).find(":checkbox:not(:checked)")
alert(x);
The reply is currently minimized Show
Responses (5)
  • Accepted Answer

    Monday, October 23 2017, 04:16 PM - #Permalink
    0
    Will,

    Is the goal to have the existing values still selectable when you do the update? Like instead of 4 options to pick from now you only have the two selected options selectable so you could essentially unselect only from the original selected ones?

    I'm assuming that's the case or else you could just make the field read only on the update and it would look like the state form.

    If it is the first option above that would take some clever javascript to do but take a look at doing it with jquery and using the .remove() function
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, October 24 2017, 05:37 AM - #Permalink
    0
    Brian,

    Yes, you are correct. I still want the remaining items selectable during the transition. I'm doing a variation on the old Voting sample that was included in Teamtrack. It's for developers installing into different environments. As they install items from the Initially Selected list the items go into the Installed list. They may not want to install all at once. That's working fine...

    1)Users initially select the environments they want their release to go into.

    2) The Next state view only shows the environments they have selected (So, the functionality I want works by default in the state view).

    3) On an install Transition the checkboxes originally selected show up along with all the items from the Initial list, those that were selected and those that were not selected. I don't want the unselected items.

    It works but it's a little confusing when checkboxes that should not be in the equation show up.

    I'll try your recommendations. Thanks.

    Regards,

    Will
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, October 24 2017, 12:25 PM - #Permalink
    0
    Will,

    Give this a try.

    Create a form action that fires on load. and have it run a javascript. Put the following in

    var x = $(GetFieldWidgetByName("MyMulti")).find(":checkbox:not(:checked)")
    for (i = 0; i < x.length; i++) {
    $(":[title='"+ x[i].title +"']").hide();
    }


    You may have to add a "\" to part of the code depending on the version of SBM but you will know as you will get a yellow indicator in the javascript screen.

    In the code substitute your multi relational field name where mine is MyMulti

    It's not the most glamorous because all it does is removes the checkboxes but due to the way we coded the multi select boxes it's difficult to get rid of all the artifacts. (See attachment )

    Hope it helps
    Brian
    Attachments:
    The reply is currently minimized Show
  • Accepted Answer

    Friday, October 27 2017, 06:29 AM - #Permalink
    0
    I've tried the code within the Action. Running the Debugger I get "SCRIPT5007: Object expected". I know the javascript is getting picked up, its bombing out. I tried a message box in the javascript and that's getting invoked. It just does not like the code. I've tried the display name "Pending Lower Environments" and the Database name "PENDING_LOWER_ENVIRONMENTS". No difference.

    Not sure where to place the / you recommended.


    var x = $(GetFieldWidgetByName("PENDING_LOWER_ENVIRONMENTS")).find(":checkbox:not(:checked)")
    for (i = 0; i < x.length; i++)
    {
    $(":[title='"+ x[i].title +"']").hide();

    }
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, November 08 2017, 11:49 AM - #Permalink
    0
    OK, finally got it to work. Problem was that I did not have the "JQuery" box checked off. Once checked and published, the project worked fine.

    Brian, thanks again for your help.

    Regards,

    Will
    The reply is currently minimized Show
Your Reply

Recent Tweets

Twitter response: "Invalid or expired token."