Scripted fields throwing error

Is it required that all three fields should be in same document?