how to assign value based on multi selection of CheckBox

135 views
Skip to first unread message

buzz...@gmail.com

unread,
Jul 23, 2015, 1:34:49 AM7/23/15
to Fujitsu RunMyProcess Developer Community
hi Team
I am new to RMP. Could you guide me on how to assign a value based on checkbox selection.

for instance if check box has the following options:
1) TABLE 2) FLOOR 3) MAT 4) SOFA

if table and floor is selected , then we need to assign value 5 to field (RESULT).

Thank you
Karthik

Murali

unread,
Jul 23, 2015, 4:34:57 AM7/23/15
to Fujitsu RunMyProcess Developer Community, buzz...@gmail.com, buzz...@gmail.com
Hi Karthik,

Hope you are using the custom list for displaying the Check Box Items. You can define values for each item as 1,2,3,4 against each Item.

And use below sample code in JS widget that listens to Check Box widget(Value Variable, i.e multi_select)  to set the value of field RESULT(id_result).

var values_array = [[multi_select]];
var res = 0;

for(index = 0; index < values_array.length; index++) {
    res += Number(values_array[index]);
}
id_result.setValue(res);

Note that, to assign the value as 5 for your requirement, you need customize above code or custom list item values.
Let us know if this helps.

Regards,
Murali

buzz...@gmail.com

unread,
Jul 25, 2015, 4:40:11 AM7/25/15
to Fujitsu RunMyProcess Developer Community, mkumma...@runmyprocess.com

hi murali , i guess my question was not clear.

my point is very basic , we are conducting q&a (test). where for example if one of the question is

1) what are the promotional products for july?

options are
1) TABLE 2) FLOOR 3) MAT 4) SOFA ( check-box, answers using custom list)


now if the user selects table and floor

then in another field called: RESULT

RESULT : CORRECT ( If table and floor are selected)
RESULT : WRONG ( If anything else is selected)

Sweta Suman

unread,
Jul 25, 2015, 6:45:56 AM7/25/15
to suppor...@runmyprocess.com, buzz...@gmail.com
Hi Kartik,

Firstly you have get selected check_box value into variable using widget_id.getSelectedValue();
Then you can use loop and If-else condition to check if selected value is correct or incorrect and accordingly set the variable RESULT.

Try executing below sample code-

var selected_val = id_check_box.getSelectedValue();
var val =JSON.parse(selected_val);
var result;
for(i=0;i<val.length;i++)
{

 // test1 and test2 are value of custom list and not label
 
 if(val[i]=="test1" ||val[i]=="test2")
  
  {
  result = "correct";
  }
  else
  {
  result ="incorrect";
  }
}
alert(result); 

Hope this helps you.


--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/09b277f1-4d46-4007-b340-5cc2483469c7%40runmyprocess.com.
For more options, visit https://groups.google.com/a/runmyprocess.com/d/optout.



--
Thanks,
Sweta 
Fujitsu RunMyProcess Support
Reply all
Reply to author
Forward
0 new messages