Thanks for the great module

With execute arbitrary php script I want to copy the date value into another date field within the same content type

field_date2013 = new field (with collect end date enabled)
field_date2013start = old field

$object->field_date2013[0]['value'] = $object->field_date2013start[0]['value'] ;
node_save($object);

I get this error;

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /www.drupal.com/dicknorman/batch?id=9&op=do StatusText: Service unavailable (with message) ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7633 of D:\www.drupal.com\dicknorman\includes\common.inc).

What am I doing wrong?

Comments

bojanz’s picture

There's no $object. It's $entity.
Try with that.

bojanz’s picture

Status: Active » Closed (fixed)
SharonD214@aol.com’s picture

Issue summary: View changes

I'm having the same issue here. Using the following:

$entity->field_journal_expiration_date[0]['value'] = $entity->field_date_expiration[0]['value'] ;
node_save($entity);

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=773&op=do StatusText: Service unavailable (with message) ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7697 of \Sites\drupal\includes\common.inc).

Any help would be great!

Thanks
Sharon

jesss’s picture

In case anybody else stumbles onto this looking for the solution, here's the correct code:

$entity->field_new_date['und'][0] = $entity->field_original_date['und'][0];
node_save($entity);
leisurman’s picture

I can copy one custom date field to another custom date field using this code and it works:

$entity->field_date2['und'][0] = $entity->field_date['und'][0];
node_save($entity);

But how can I copy a custom date field to the drupal post date/created field? When the two formats are different?
I tried this code but the post date comes out wrong with a date of 1969, I am using this code

$entity->created['und'][0] = $entity->field_date['und'][0];
node_save($entity);
jesss’s picture

@leisurman -- I think you just need to do an extra bit of processing to convert the data from the date field from ISO to a timestamp. I haven't tested it, but something like this should work.

$formatted_date = strtotime($entity->field_date['und'][0]);
$entity->created['und'][0] = $formatted_date;
node_save($entity);
leisurman’s picture

Thank you Jess you are right. I did not test your code but I found that Feeds tamper module can add the code to the date before its processed, its called "String to timestamp" It did the trick.