william_neff_po

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-10-24
02:00
6127 views
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
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
1 Solution
Accepted Solutions
bamos

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-10-28
00:37
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.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);
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.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);
8 Replies
bamos

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-10-24
05:16
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
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
william_neff_po

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-10-24
18:37
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
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
bamos

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-10-25
01:25
Will,
Give this a try.
Create a form action that fires on load. and have it run a javascript. Put the following in
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
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.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
william_neff_po

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-10-27
19:29
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.title +"']").hide();
}
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.title +"']").hide();
}
bamos

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-10-28
00:37
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.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);
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.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);
william_neff_po

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-11-09
01:49
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
Brian, thanks again for your help.
Regards,
Will
william_neff_po

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2018-01-18
02:45
Now one more request on this topic.... A big twist. It's working and only showing the checked boxes... Now, what I would to do is once the checked boxes are showing I would like to uncheck them..... So, final display will show available checked boxes without their check marks... Or, possibly a button on the form that would "Un Check" all selections.
william_neff_po

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2018-06-21
00:32
This worked for unchecking the multi-relational field. I removed the javascript from the field action within the field and placed it into a javascript file within the forms javascripts dropdown property. I was not able to set a breakpoint when the javascript was within the field action.
if (transition_value_var == "DESKTOP_ENVIRONMENT.REMOVE")
{
if (GetFieldWidgetByName) {
var x = $(GetFieldWidgetByName("REJECTED_LOWER_ENVIRONMENT")).find(":checkbox(:checked)"); for (i = 0; i < x.length; i++)
{
var y = x.checked
var z = x.value // Do I even need z in this code....?
if ( y == true )
{
$(":[value='"+ x.value +"']").attr("checked",false); }
else
{
$(":[value='"+ x.value +"']").hide(); //Makes the checked items read only.
}
}
}
}
if (transition_value_var == "DESKTOP_ENVIRONMENT.REMOVE")
{
if (GetFieldWidgetByName) {
var x = $(GetFieldWidgetByName("REJECTED_LOWER_ENVIRONMENT")).find(":checkbox(:checked)"); for (i = 0; i < x.length; i++)
{
var y = x.checked
var z = x.value // Do I even need z in this code....?
if ( y == true )
{
$(":[value='"+ x.value +"']").attr("checked",false); }
else
{
$(":[value='"+ x.value +"']").hide(); //Makes the checked items read only.
}
}
}
}