September 24, 200619 yr I am trying to create a script which reads records and look at their due date and number of days notice field to determine if they should be "found" in order to be displayed to the user. The days notice field (number) varies by record and depending on this field, the user will get some advance notice before the due date comes. The rest of the script is working fine but not the calculation in the Set Field command. The script is attached. Thanks in advanced for any help. Tasks.pdf
September 24, 200619 yr Why not just create an unstored calculated field with the formula: (Get(CurrentDate)+Days Notice>=Due Date) and (Get(CurrentDate)<=Due Date) and then search this field for the value 1.
September 24, 200619 yr Author Thanks for responding so fast but not sure how that 1 is entered before I can perform the find.
September 24, 200619 yr Suppose that the new field I described is called TestDue. With the formula that I gave, It gives a boolean result (0 for false, 1 for true) depending on whether the date is within the required range. So, all you need to do is go into find mode, enter a 1 in the TestDue field, and then click the find button. You can make this into script, if you like (just one step long) by using the "Perform Find" script step: Perform Find [TestDue = 1]
September 24, 200619 yr You can make this into script, if you like (just one step long) by using the "Perform Find" script step: Perform Find [TestDue = 1] But this requires adding another field (adding to field-bloat), you are searching on an unstored calc, and you still have to script a find. I'd rather skip the calc and use a Set Field[] find here - search field is already indexable and the only variable factor, Get ( CurrentDate ) can be retrieved at script execution. I should think that would be more efficient particularly with large record-sets. Shawn, I have some suggestions and questions about your script so I just inserted them where appropriate. I hope this is helpful to you. Find Tasks for TASKS NOTIFICATIONS #Find tasks based on criteria to notify user # Set Error Capture [ On ] Go to Layout [ “List View Expanded” (Tasks) ] Show All Records [color:green](remove - unnecessary) Enter Find Mode [ ] Go to Field [ Tasks::Due Date ] [color:green](remove - unnecessary) Clear [ Tasks::Due Date ] [color:green](remove - unnecessary) [ Select ] [color:green](remove - unnecessary) Set Field [ Tasks::Due Date ; [color:green]Get ( CurrentDate ) & ".." & Get ( CurrentDate ) + Date-Tasks::Days Notice ] Perform Find [ ] # #If no records, exit # If [ Get ( FoundCount ) = 0 ] [color:green](change to If [ not Get ( FoundCount) ] … it saves an evaluation). Show Custom Dialog [ Title: "Audit Trail"; Message: "no found records"; Buttons: “OK” ] Show All Records Go To Layout [ original layout ] [color:green](add this to return User whence they came. You may want to drop them on List View Expanded with all records showing but probably not.) Exit Script [ ] End If # Show Custom Dialog [ Title: "Audit Trail"; Message: "Records found!"; Buttons: “OK” ] [color:green](consider omitting this entirely. Of course there were records found or the User would get the other message. # #Display custom message with each task to be displayed to the user via LOOP # Set Variable [ $LoopCounter; Value:0 ] Go to Record/Request/Page [ First ] [color:green]Why are you displaying each found record’s detail in a Custom Dialog? When they click OK, all they are doing is viewing the next Custom Dialog – there is no User action required here that I can tell. The User probably saw several tasks (while reading the Custom Dialogs) that they wish to act upon but you never present them with a list - you end with Show All Records. From User perspective, one final message which says “There are “ & Get ( FoundCount ) & “ Task Alerts found. You may want to act on these Tasks” and then present a sort list (most critical DueDate at the top) of the found set. Just a thought ... Loop Set Variable [ $LoopCounter; Value:$LoopCounter + 1 ] Show Custom Dialog [ Title: "TASKS Alert!"; Message: "Tasks ID: " & Tasks::Task ID & " " & Tasks::Tasks Name & " " & " " & "Due on: " & Tasks::Due Date; Buttons: “OK” ] Go to Record/Request/Page [ Next; Exit after last ] End Loop # #Displays the total number of TASKS Alerts in a Custom Message Show Custom Dialog [ Title: "TASKS Alert!"; Message: "You had " & $LoopCounter & " TASKS Alerts this time! You may want to act on the task(s)."; Buttons: “OK” ] Enter Browse Mode [color:green](remove - unnecessary) Show All Records I didn't indicate in green removing your entire loop/custom dialog process but I think you get my direction on it. LaRetta
September 24, 200619 yr Author Thank you all for your suggestions. They're very helpful. I believe I'm on the right track now.
Create an account or sign in to comment