Hello All,
Recently i had a requirement wherein i wanted to delete some records in Script.
Its very simple but i was missing a very basic thing.
This script deleted only the first record not subsequent record, reason was just after deleting the records the cursor was set to First Record so NextRecord was not fetching any results.
Final Script required me to call FirstRecord again after performing DeleteRecord.
Working Code:
Recently i had a requirement wherein i wanted to delete some records in Script.
Its very simple but i was missing a very basic thing.
while(FRecord) { FRecord = DeleteRecord(); FRecord = NextRecord(); } |
This script deleted only the first record not subsequent record, reason was just after deleting the records the cursor was set to First Record so NextRecord was not fetching any results.
Final Script required me to call FirstRecord again after performing DeleteRecord.
Working Code:
with(ErrorBC) { ActivateField("Error Object"); ClearToQuery(); SetViewMode(AllView); SetSearchSpec("Error Object", "Todays Failure");//Deallocate 0-D5B3 ExecuteQuery(ForwardBackward); var FRecord=FirstRecord(); while(FRecord) { FRecord = DeleteRecord(); //This did the trick. The Cursor would always be reset to First record and the deletion went fine. FRecord=FirstRecord(); } } |
THANKS!! ITS WORKS!
ReplyDelete