Copy field from a parent module to child module [Solved]

Hi

I have three custom modules, lets say A,B,C. The A has a one to many relation with B and B has one to many relation to C. What i want to do is to have a text field in C which inherit the name field of A when created.

I am new in suiteCRM and what i found so far is a kind of abstract or linking to not existed sugarCRM links.

Thank you in advance

1 Like

Hi, welcome to the Community! :tada:

The concept of “inheriting” a field doesn’t exist as such in SuiteCRM; what you could do is copy it over, when saving a record. This can be done in code, with Logic hooks, or defined from the UI as a Workflow.

So in module B, when the record is created, for example, it can copy the field you want from its parent record A.

The same goes for record C grabbing the value from record A.

Note that this won’t cover all possibilities of the field being edited in one place, in the other, or after the moment of creation. So you’ll have to check if this simplified process fits your needs.

For anything better than that you will need some bits of PHP custom code.

Thank you for your reply.

It is exactly what i need, the problem is that i am struggling with Workflow two days now with out success
( i am new as i said before).

Can you please give some more detailed instructions?

Hi

Apparently that only was needed is to struggle a couple more hours and figured out.

1 Like

@Babis Could you please post your full solution with all details so that everyone who has the same issue can benefit of your work without having to do it all again?

Thanks! :wink:

2 Likes

Lets say that we have three Modules, A B and C.
First i create a receiving field lets say parent_name as textfield in modules B and C. That step is not necessary you can use any field that is text. I didnt try other field types, may it works.

Create a new Workflow with some name.
On Basic panel set
WorkFlow Module: B
Run On: New Records
Left the other fields to defaus

On Condition panel i set some silly condition like
Module: B
Field: Description
Operator: Not Equal To
Type: Value
Value: asdfg

On Actions panel
Select Action: Calculated Fields
Parameters: (not changed)
Relation parameters: (module) A, (field)name (in my case the module was in the form A:A)
Press [Add Relation parameter]
That makes a line like:
A:A name Raw value {R0}
Formulas
parent_name (and press Add Formula)
In the new line that appears write: {R0}

Press Save .

Thats it now every time you create a new record of module B has autopopulate its parent_name field with the content of name field in module A

In the same way you can make a new Workflow that copies the parent_name of B to the parent_name of C.
By the way i want to thank you the SuiteCRM team for everything.

3 Likes

Instead of a silly condition, you can just leave the Condition area blank.

Anyway, thanks for sharing the solution!

Thank you so much! It worked. It was still a process. For other user’s reference, make sure that the field type you are populating matches with the field type of the data you are trying to populate it with.

1 Like