Google App script for the block to store values in spreedsheet

Anybody help me to write a script for the above block design