Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » trigger creation of a record

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 142 Views
  • voodoochile
    Community Member
    52 Posts

    trigger creation of a record Link to this post

    Hi all

    I have a dataobject called nuts and another called bolts, I am trying to figure out how when a new entry for nuts is created to also create a new entry for bolts.

    I am thinking to use onafterwrite but not sure of what to use to request the record creation.

    Can anyone please point me in the right direction?

  • martimiz
    Forum Moderator
    1078 Posts

    Re: trigger creation of a record Link to this post

    Something simple, to get you going, in this case assuming Bolt has a NutID

    $bolt = Bolt::get()->filter(array('NutID' => $this->ID));
    if (!$bolt) {
    $bolt = new Bolt():
    $bolt->NutID = $this->ID;
    $boltID = $bolt->write();

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.