I have made a hook_node_insert which when I create a group content of type A, it create a node group. I want to associate my type A with the created group with the field audience. I have changed the field group audience like that
$nodeA->group_audience = array( LANGUAGE_NONE => array( '0' => array( 'gid' => $group->gid, ), ), );
But it doesn't save the data into the database. I have tested with node_save but I have the error that primary key nid is duplicated.