Sign up |
I have created a parent (Order Header) to children (Order Detail) relationship and am trying to prime related key field in the child record from parent record upon create. The order detail should inherit the order number from the parent record. I was assuming this would happen if I established the "related records" in the order header to the order detail records. This is in the admin back end BTW
Since it doesn't seem to happen, how can I use the default value field to prime it with the parent parent num field?
Am I missing something here?
This is something that CMS Builder doesn't currently do. But we've found a solution that uses the default value field.
If you edit the list field that contains your category field, and add this for the default value:
<?php preg_match('#([0-9]+[^0-9]*)$#', @$_REQUEST['returnUrl'], $out); echo @$out; ?>
you should find that the field will have the correct value selected by default.
So this statement will look in the URL for the returnUrl variable, and then uses preg_match to return the last numbers in the string, which will be the num field. It will return an array of numbers, and the first needs to be displayed.