I am trying to do a CREATE FOR EACH process where the loop is WEEKEND_DAY between two dates input by the user but the thing I need to create must include the date itself. So something like
CREATE Duties FOR EACH WEEKEND_DAY between UserInput.Start_Date and UserInput.End_Date WITH Duties.StartDate=[The date we've got to in the loop]
UserInput is a non persistent BO and the gap between start and end could be up to 6 months - but I don't know how to grab the date we are at in the loop - Will that be in WEEKEND_DAY or is this a job for LOOP_ITERATION
My other problem is - I don't see any reference to WEEKEND_DAY in any of the manuals
Edit: Found an example in Programmers Reference so can now confirm that FOR EACH DAY BETWEEN..... With Duties.StartDate=DAY syntax works but whenever I swap it for EACH WEEKEND_DAY, I get a syntax error (like somebody forgot to do the code for WEEKEND DAY - which is a shame).
So how can I create a process that only creates records for weekend days
HELP with FOR EACH
HELP with FOR EACH
Rocketman
V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
Re: HELP with FOR EACH
why not just create the records for all (including weekend) days then remove the weekends with:
FIND BO WHERE DATE Between firstdate and last date and (DAY_OF_WEEK(datefield) = 1 or DAY_OF_WEEK(datefield) = 7)
DELETE BO
Bruce
FIND BO WHERE DATE Between firstdate and last date and (DAY_OF_WEEK(datefield) = 1 or DAY_OF_WEEK(datefield) = 7)
DELETE BO
Bruce
Re: HELP with FOR EACH
Just trying not to waste too many ID resources
Rocketman
V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
Re: HELP with FOR EACH
got to chime in here while Mark is still sleeping in Mongolia...
this is a job for... knowing your date range, you init the NP BO and it loops until the final date.
in the process it creates records only when its Sat/Sun, then increments the test date.
easy
this is a job for... knowing your date range, you init the NP BO and it loops until the final date.
in the process it creates records only when its Sat/Sun, then increments the test date.
easy
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: HELP with FOR EACH
Yeah, Jaymer. I was heading that way. It's just so frustrating that the following example has been in every manual from 8.1 through 8.6 but WEEKEND_DAY just doesn't seem to exist. It would have been three lines of code.
"1. CREATE Transaction FOR EACH Account
2. CREATE Transaction FOR EACH
DAY/WEEK/MONTH/QUARTER/YEAR/WEEK_DAY/WEEKEND_DAY BETWEEN
Account.OpeningDate AND Account.ClosingDate
3. CREATE Transaction FOR EACH NUMBER BETWEEN 1 AND 3
4. CREATE Attachment FOR EACH FILE IN 'c:/mydirectory'
The action in the first example will create as many instances of the Transaction object as
there are instances of the Account object in the Context.
The action in the second example will create as many instances of the Transaction
object as there are days in the specified date interval. The date interval includes both
starting and ending dates."
"1. CREATE Transaction FOR EACH Account
2. CREATE Transaction FOR EACH
DAY/WEEK/MONTH/QUARTER/YEAR/WEEK_DAY/WEEKEND_DAY BETWEEN
Account.OpeningDate AND Account.ClosingDate
3. CREATE Transaction FOR EACH NUMBER BETWEEN 1 AND 3
4. CREATE Attachment FOR EACH FILE IN 'c:/mydirectory'
The action in the first example will create as many instances of the Transaction object as
there are instances of the Account object in the Context.
The action in the second example will create as many instances of the Transaction
object as there are days in the specified date interval. The date interval includes both
starting and ending dates."
Rocketman
V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
Re: HELP with FOR EACH
I know that would’ve been easy, but
There’s a great amount of satisfaction when you get a WHILE loop working correctly
There’s a great amount of satisfaction when you get a WHILE loop working correctly
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: HELP with FOR EACH
Is it possible to include the NUMBER value into an attribute of every instance that created?
example: I want the Transaction.No = A-1, A-2, and A-3
I have try like rule in this below but got error
Code: Select all
CREATE Transaction FOR EACH NUMBER BETWEEN 1 AND 3 WITH Transaction.No='A-'+NUMBER
Regards,
Suwandy
-----------------
Kisaran - Indonesia
Suwandy
-----------------
Kisaran - Indonesia
Re: HELP with FOR EACH
I am fairly sure the LOOP_ITERATION can be used for this. Search the forum and or docs.
I think the syntax would be something like:
Then you can have business rule that adds the A or have another attribute where you combine letter with number.
I think the syntax would be something like:
Code: Select all
CREATE Transaction FOR EACH NUMBER BETWEEN 1 AND 3 WITH Transaction.No=LOOP_ITERATION
Henrik (V8 Developer Ed. - Windows)
Re: HELP with FOR EACH
OMG, I didn't read the text in the rectangle of AwareIM user guide.
Many thanks, it works now..
Regards,
Suwandy
-----------------
Kisaran - Indonesia
Suwandy
-----------------
Kisaran - Indonesia