Hello Everyone,

I am working on Drupal Commons Notifications and I am using message module to generate custom messages on the site as notifications to the user :

In my

hook_message_type(){
   $items['new_software_release'] = entity_import('message_type', '{
   "name" : "new_software_release",
   "description" : "BroadSoft Notify: A new software release available.",
   "argument_keys" : [],
   "argument" : [],
   "category" : "message_type",
   "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } },
   "language" : "",
   "arguments" : null,
   "message_order_display_name" : { "und" : [ { "value" : "Order", "format" : null } ] },
   "message_text" : { "und" : [
         {
         "value" : "New Software release [message:field-node-ref:title]",
         "format" : "full_html",
         "safe_value" : "New Software release"
       }
         {
         "value" : "New Software release",
         "format" : "full_html",
         "safe_value" : "New Software release"
       }
     ]
   },
   "rdf_mapping" : []
 }');
return $items;
}

I want the message to be created on node update

So

  hook_node_update(){
    dpm('A notifictation is sent to all the users of this group for the new software update.');
   // if($node->type == "broadsoft-software"):
    $message = message_create('new_software_release', array('uid' => $node->uid));
    // Save reference to the node in the node reference field, and the
    // "publish" state (i.e. if the node is published or unpublished).
    $wrapper = entity_metadata_wrapper('message', $message);
   // $wrapper->field_node_ref->set($node);
   // $wrapper->field_published->set($node->status);
    $wrapper->save();
     //   endif;
}

when I comment this line
$wrapper->field_node_ref->set($node);
it throw's me error for unknown data type field reference

 EntityMetadataWrapperException: Unknown data property field_node_ref. in EntityStructureWrapper->getPropertyInfo() (line 335 of /var/www/html/filedepot/profiles/commons/modules/contrib/entity/includes/entity.wrapper.inc).```

Am I missing something here ?

Comments

thedrupalkid created an issue.