The CreatorCon Call for Content is officially open! Get started here.

I want to check values of fields in an array in business rule. Please help

divya23
Tera Contributor

Hi,

I have fields on the table as mentioned in array. But when i try to display the value in for loop , it is not displayed. It enters the for loop though.

Below is the code in the business rule.

var daysOfWeek = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];

for(i=0;i<daysOfWeek.length;++i)

{

gs.addInfoMessage(current.daysOfWeek[i]);

if(current.daysOfWeek[i] > maxHoursPerDay){

gs.addInfoMessage(current.daysOfWeek[i]);

gs.addErrorMessage(gs.getMessage('Maximum hours per day cannot exceed {0} hours', maxHoursPerDay));

current.setAbortAction(true);

}

}

Please let me know what is wrong in the code.

When i try to display current.monday directly , it displays the right value of the field.

Why is it not fetching the field name from array? Please help.

Thanks,

Divya.

1 ACCEPTED SOLUTION

vitaly_sukharev
Kilo Guru

Hi Divya,



To get it working you need to replace "current.daysOfWeek[i]" with "current[daysOfWeek[i]]" in your script.


View solution in original post

5 REPLIES 5

Thank you for your reply Vitaly. It works fine now..