Problem is at line below:
$velocityPortletPreferences.setValue('rootLayoutId', 'f74bd692-715f-4532-8490-dee211bebed8')
It should be
$velocityPortletPreferences.setValue('rootLayoutUuid', 'f74bd692-715f-4532-8490-dee211bebed8')
It should be rootLayoutUuid
Regards