So I have a table set up and need to add up the hours for specific activities.
I have Activity() as an array of drop down boxes with things like "holiday, regular, vacation, etc"
Monday(), Tuesday() etc, are numeric field arrays.
and i am trying to popluation totals from the differnet Activities.
Using Java like this and it doesn't seem to be working:
for (var i = 0; i < 12; i++)
{
if (Activity[i].rawValue = "Holiday"){
$.Value = Monday[i].value + Tuesday[i].value + Wednesday[i].value + Thursday[i].value + Friday[i].value
}
}
Am i missing somethign here?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Use FormCalc (not JavaScript). I think you have a "total" field for each week (i.e. total and Monday are siblings?). If so
//////////////////////////////////////////////////////////////////////
if (Activity == "Holiday")then
$ = Sum(Monday, Tuesday, Wednesday, Thursday, Friday)
else
$ = 0
endif
//////////////////////////////////////////////////////////////////////
If you are totalling for multiple weeks (all the weeks),
if (Activity == "Holiday")then
$ = Sum(week[*]Monday, week[*]Tuesday, week[*]Wednesday, week[*].Thursday, week[*].Friday)
else
$ = 0
endif
//where each group of days is wrapped in a subform named "week"
//////////////////////////////////////////////////////////////////////
Finally, this uses the "boundItem" values NOT the displayed value. So:
if (Activity == "Holiday")then
will only work if the boundItem value is used. Look in the BindingTab for the dropdown box to understand and setup some boundItem values. They are strings and use "" when referencing strings. So, 1 is best referenced as "1" as in
if (Activity == "1")then
//////////////////////////////////////////////////////////////////////
Finally, if statements need == (don't use a single =).
Hope this helps!
Stephen
Views
Replies
Total Likes
Hi,
this.resolveNode( "Monday[" + i + "]").rawValue; //there are 3 strings concatonated using + within the ()
Hope this helps
Stephen
Views
Replies
Total Likes
The script is on the Calcuate event of the the "total" field so as the add hours on differnet days the total will change.
So what i am trying to do is run through the different activity fields and find with column is "Holiday" if it happens to be Activity[5].rawValue = "Holiday" then I want the totals for Monday[5].rawValue, tuesday, wednesday etc.
Views
Replies
Total Likes
So i switched to FormCalc and got this to work
for I=0 upto Activity.nodes.length - 1 step 2 do
if (Activity[I] eq "Holiday") then
HolidayHours.rawValue = Monday[I] + Tuesday[I] etc...
endif
endfor
Probelm is I can't figure out in what even to place it so it is updated everytime the user edits any of the hours.
Views
Replies
Total Likes
Hi,
Use FormCalc (not JavaScript). I think you have a "total" field for each week (i.e. total and Monday are siblings?). If so
//////////////////////////////////////////////////////////////////////
if (Activity == "Holiday")then
$ = Sum(Monday, Tuesday, Wednesday, Thursday, Friday)
else
$ = 0
endif
//////////////////////////////////////////////////////////////////////
If you are totalling for multiple weeks (all the weeks),
if (Activity == "Holiday")then
$ = Sum(week[*]Monday, week[*]Tuesday, week[*]Wednesday, week[*].Thursday, week[*].Friday)
else
$ = 0
endif
//where each group of days is wrapped in a subform named "week"
//////////////////////////////////////////////////////////////////////
Finally, this uses the "boundItem" values NOT the displayed value. So:
if (Activity == "Holiday")then
will only work if the boundItem value is used. Look in the BindingTab for the dropdown box to understand and setup some boundItem values. They are strings and use "" when referencing strings. So, 1 is best referenced as "1" as in
if (Activity == "1")then
//////////////////////////////////////////////////////////////////////
Finally, if statements need == (don't use a single =).
Hope this helps!
Stephen
Views
Replies
Total Likes
Thanks for your patience. Working pretty good now.
Views
Replies
Total Likes
So I have a Total Field that on the calculate event i have:
Sum(Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday)
However when i add your if statement:
if (Activity == "Holiday")then
Holiday.rawValue = Sum(Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday)
else
Holiday.rawValue = 0
endif
The total field no longer totals anything UNLESS I choose holiday for the Activity field.... Any idea why that is?
Views
Replies
Total Likes
Hi,
I made the assumption that was what you wanted. So the
else
$ = 0
part of the script does that. What is it you want it to do instead?
Stephen
Views
Replies
Total Likes
Oh sorry yes. I guess i need to go get lunch.
I have a "Total" column and then a a break out section of what the the hours are as monday can have 3 hours of Vacation and 5 hours of regular, so i just had to tweak the if statement and yes replace the $=0 with what i wanted.
Views
Replies
Total Likes
Hi,
I'm still not sure of how your form is supposed to work.
I say $ = 0 //which means "this" equals zero
but you say Holiday.rawValue = 0 //which means "Holiday" equals zero
Is Holiday the field that the script is on or some other field?
Views
Replies
Total Likes
Yes. There is the "Total" field which gets the $=0 but I added "holiday" to total just holiday hours. So I took your formula and added a bunch elseif statements.
I can post my final formula later as now I am out of the office.
Best Regards,
Benjamin Speich
Customer Service Specialist
Mentice Inc.
Cell 312-504-8820
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies