Not sure if this is the problem but you have a forward slash between StockTake and Stocktake. The rest of your slashes are backward slashes.
Yes I realized this after I had put this up however changing the slashes has not affected it .
I would suggest that if the script worked before the restore and does not work after the restore then the only logical conclusion is that the OS is preventing the action due to permissions issues.
Furthermore steps 2 and 3 in your script are misplaced as any sorting should be done after find is performed.
And it's unnecessary to use Show All Records …
Here's an alternative:
Enter Find Mode
# [ do it first, so no records need be loaded in the GtL target table ]
Go to Layout [ Items ( Items ) ]
Set Field [ … ]
Set Error Capture [ on ]
Perform Find [ no restore ]
If [ not Get ( FoundCount ) ]
# [ error handling ]
# [ process found set; any sorting should only happen now ]
If you use Enter Find Mode/Set Field/Perform Find, you shouldn't use PF with Restore – that will get confusing …