I think you've got it backwards.
Assuming Stock Material can be used in different Stock Items, you should have Stock Material Total Weight ( which is really a Stock Material Join table ) be between Stock and Material. You need to add records to this Join table to build up a record in Stock. Then have a calc field in Stock Sum() on the Weight of Stock Material Join.
Once you've got the weight calculating correctly, you've got to get the user behavior down. That could easily be done with an OnObjectExit script trigger on the Portal.
Thanks for your advice. I reworked and remove the TO "Stock Material Total Weight" & the Total Weight field in Stock Material table. Instead I created a simialr calculation field in Stock table to sum the Weight field in Stock Material table as recommended by you. Learn something new ;-)
At this junction, no script trigger is being applied to the Weight field (of Stock Material) as well as the portal. The user can freely modify the weight field and the total weight at the bottom of the portal will get changed everytime the weight of the individual material is being modified. This is good as the user get to know the updated total as she starts modifying.
I created a simple script to check if the total of the weight for all the sub material is equal to 100 and Set Script Trigger to the Portal (onobjectexit)
I tested it and it works BUT unfortuanately, after closing the message prompt, I am still able to go to other record or another layout (eg. via a button). Is there a way to "Prevent Totally" from ignoring this constraint and that the user must resolve the total weight to 100 before she can move to other screen? I set script trigger at the layout setup (onlayoutexit) to this same script and doesn't help, meaning I can still exit to other layout.
I learn and I appreciate. Thanks.
You could have this operation run from a separate/new Modal window which the user cannot exit until your specific criteria are met.
Keep in mind if you do this, by whatever means, you must provide some sort of roll-back to cancel the entire operation if your user realizes they can't complete the operation at that time -- otherwise they will probably force-quit the application!