AnsweredAssumed Answered

Exporting records scripting problems

Question asked by cmspe on Sep 28, 2010
Latest reply on Sep 29, 2010 by cmspe

Title

Exporting records scripting problems

Post

I'm trying to write a script that will export student data.  The first export in the script is one record per student.  Not a hard thing to figure out.  The second export is more difficult.  Each student can have zero to multiple records in the second export.  Here is the script I have written so far:

Go to Layout ["Export" (Students)]

Perform Find [Restore] This finds all the students who are not assigned a teacher

Loop

Go to Related Record [Show only related records; from table: "Daily Records 4"; Using layout: "Daily Export" (Daily Records); New Window] Problem, if there are no related records, the script stops.

Export Records [No dialog; "Daily Export.csv"] *If "Daily Export.csv" already exists, is there a way to append a number (ie "Daily Export2.csv") on the end instead of replacing the file?

Delete All Records []

Close Window [Current Window]

Go to Record/Request/Page [Next; Exit after last]

End Loop

Export Records [No dialog; "Unassigned.csv"] *See previous note.

Delete All Records[]

Go to Layout ["Home" (Teachers)]

This works except where there are no related records (line 4) and the problem of overwriting previous exports (lines 5 and 10).  How do I write a "Exit Loop if" or other script to compensate for this occurrence and is it possible to have a custom export name other than having the dialog come up?

Outcomes