Skip to main content
Source Link
kenorb
  • 14.3k
  • 10
  • 100
  • 170

Below is the final solution. Both questions have been answered. I finally figured out why the script was not firing. I was having the VBO on the entity (people_notes) and not the referenced entity (people). Because the people_notes was being created with the action there was nothing being passed to the action. Once I switched the VBO to people it fired successfully and created the people_notes entity.

Also @chadpeppers originally suggested entity_metadata_wrapper but that did not work due to not have a setter function defined for the uid field. I defined a setter function and then entity_metadatawrapper worked correctly.

global $user; $entity_notes = entity_create('people_notes', array()); try { $wrapper = entity_metadata_wrapper('people_notes', $entity_notes); $wrapper->uid->set($user->uid); $wrapper->field_people_reference->set($entity->PeopleId); $wrapper->field_signed->set(1); $wrapper->save(); drupal_set_message(t('Signature Scrubbed!')); watchdog('Signed Petition', 'Signed Petition action fired!'); } catch (EntityMetadataWrapperException $exc) { watchdog( 'Signature Scrubbed Action', 'See ' . __FUNCTION__ . '() <pre>' . $exc->getTraceAsString() . '</pre>', NULL, WATCHDOG_ERROR ); } 
Post Made Community Wiki by kenorb