Help with a bit of code
Hi, I have some code on a button that generates 4 bookings a year, currently it generates bookings for:
1st March, 1st June, 1st September, 1st December
What can I change in the code below so that it creates a booking for all 12 months of the year. The code below generates 4 bookings only a year. I know it's a real simple solution for someone out there that knows what they are doing, unlike me! I have a feeling that it's to do with the bold code?
let year := year('Insert Date');
let month := month('Insert Date');
let day := day('Insert Date');
let original := this;
let k := 'Number of Insertions';
'Number of Insertions' := null;
for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] do
if i < k then
let inserted := (create '3 - Bookings');
inserted.(Publication := original.Publication);
inserted.(Section := original.Section);
inserted.('Ad Rate' := original.'Ad Rate');
inserted.('Ad Size' := original.'Ad Size');
inserted.('Booked By' := original.'Booked By');
inserted.(Contact := original.Contact);
inserted.('Insert Date' := date(year, month + i * 3, day))
else
void
end
end
3 replies
-
Sorry, here's the correct code
let year := year('Insert Date');
let month := month('Insert Date');
let day := day('Insert Date');
let original := this;
let k := 'Number of Insertions';
'Number of Insertions' := null;
for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] do
if i < k then
let inserted := (create '3 - Bookings');
inserted.(Publication := original.Publication);
inserted.(Section := original.Section);
inserted.('Ad Rate' := original.'Ad Rate');
inserted.('Ad Size' := original.'Ad Size');
inserted.('Booked By' := original.'Booked By');
inserted.(Contact := original.Contact);
inserted.('Insert Date' := date(year, month + i * 3, day))
else
void
end
end -
I though its a case of changing the 3 to 11
-
if you want to create a booking for each month of the year then you can try something like:
let xYear := year('Insert Date'); let xMonth := month('Insert Date'); let xDay := day('Insert Date'); for i in range(1,13) do let inserted := (create '3 - Bookings'); inserted.( 'Insert Date' := date(xYear,i,xDay) ) end
If that works then you add back all of the other fields.
The range() command is very helpful in this case.
I also renamed the variables so they don't get confused with Ninox commands.
Content aside
- 2 mths agoLast active
- 3Replies
- 27Views
-
2
Following