Hi All,
How to set the relate field value as selected , based on the value of a field on same module or another module ?
Please help me to find a solution.
Hi All,
How to set the relate field value as selected , based on the value of a field on same module or another module ?
Please help me to find a solution.
Hi Sino Thomas, I would love to help but you will need to give a few more details...
Let's say you have related field A which relates your current record to one in ModuleA.
You want to fill A based on field B. What kind of field is B? Is it also a relate field to ModuleA?
If B is in another module, how is the module that B is in (ModuleB) related to ModuleA?
Having a better picture of your scenario would help in trying to answer your question.
FrancescaS
I need to set MODULE A relate field (RL1) value in MODULE B Relate field (RL2) as default value when creating a new record in MODULE B. There is a one to many relationship from Module A to Module B
If you are creating B from a subpanel on record A you should be able to get the data for ModuleA using the context:
var parent_model = this.context.parent.get('model');
That model contains the parent id and the module IF you started from a subpanel on ModuleA when you were creating B. If you create directly from the B module then we don't know what A is and the parent_model will be empty.
parent_model.get('id'); // will return the id of A record
parent_model.get('_module'); // will return the name of the A module
You can now get RL1 from A using parent_model.get('RL1') and copy it to RL2.
If you want to set RL2 when B is related to A regardless of where you are starting from, then you can use an after_relate logic hook. There you can retrieve the beans for both sides of the relationship and copy the relate field from A to B.
Be careful with the logic hook because it will override any other value you have in RL2 unless you put checks in place.
I hope this answers your question.
Francesca
Is it possible to achieve it by without code modification, that means by any option through the Administration?
Is it possible to achieve it by without code modification, that means by any option through the Administration?
I can't think of a way, but that does not mean there isn't one.