Page 1 of 1

restrict related record

PostPosted: Tue Jun 19, 2012 9:33 pm
by cookie720
Hi all,
Hopefully my last question for a while (not likely though :mrgreen: )
I need to restrict clients in my orders, ONE client per order,
When looking up related records in my orders, in my clients tab, I want to disable that add new clients record button. If not then upon creating the record, disallow it.

Im guessing a function in my delegate class, something to do with triggers, beforesave, or beforeAddRelatedRecord?

Ill have a go:


Code: Select all
function beforeInsert(&$record){
        $response =& Dataface_Application::getResponse();
        if ( there is no record ){
            insert client
        } else {
            return PEAR::raiseError(
                        "Cannot have more than one client per Order.  Record could not be inserted",
                        DATAFACE_E_NOTICE);
        }
    }



Thanks!

Re: restrict related record

PostPosted: Wed Jun 20, 2012 10:20 am
by shannah
Hard to comment as I don't know how you are adding the clients. Using the grid widget on the new record form, or adding clients individually with the add related record form?

Re: restrict related record

PostPosted: Thu Jun 21, 2012 5:00 am
by cookie720
Yes the add related record