public function createInRelation() {
    $this->requireTransaction();
    $request = $this->getRequest();

    // create new object
    $oidStr = null;
    $sourceOid = ObjectId::parse($request->getValue('sourceOid'));
    $relatedType = $this->getRelatedType($sourceOid, $request->getValue('relation'));
    $request->setValue('className', $relatedType);
    $subResponse = $this->executeSubAction('create');
    if (!$subResponse->hasErrors()) {
      $createStatus = $subResponse->getStatus();
      $targetOid = $subResponse->getValue('oid');
      $targetOidStr = $targetOid->__toString();

      // add new object to relation
      $request->setValue('targetOid', $targetOidStr);
      $request->setValue('role', $request->getValue('relation'));
      $subResponse = $this->executeSubAction('associate');
      if (!$subResponse->hasErrors()) {
        // add related object to subresponse similar to default update action
        $persistenceFacade = $this->getPersistenceFacade();
        $targetObj = $persistenceFacade->load($targetOid);
        $subResponse->setValue('oid', $targetOid);
        $subResponse->setValue($targetOidStr, $targetObj);
        $subResponse->setStatus($createStatus);

        // in case of success, return object only
        $oidStr = $subResponse->hasValue('oid') ? $subResponse->getValue('oid')->__toString() : '';
      }
    }

    // prevent commit
    if ($subResponse->hasErrors()) {
      $this->endTransaction(false);
    }
    $this->handleSubResponse($subResponse, $oidStr);
  }