Connect a related record via Workflow

Hi,

quite simple question.

I have Module A and Module B.

In Module A there is a new record created by incoming Mails. Some Values of the Record are set by the Subject of the Mail via Workflow.

In This context i'd like to relate/connect that record to another record in a different Module (B) depending on the specific Value in Subject.

For e.g.

Subject is: "Car Type 123 is having a Problem"

So depending on that

Field 1 - Product "Car"
Field 2 - Type "123"
Field 3 - Problem

Field 4 - State "Open"

are getting a specific value - that works totally fine.

But the missing part is a relationship to the Module B and the record there.

Like - action -> link record to related Module B and record "Failure Type 098"

I hope it's clear what i'm looking for.

 Thanks!

  • I don't have Workflow (BPM) because I'm on Professional but I can give you a non-Workflow solution.

    I assume you are using the Emails module to receive the email and create the record in Module A.

    That means you probably have a relationship between Emails and ModuleA.

    When an Email comes in the Email record is Related to ModuleA.

    In ModuleA you can add an after_relationship_add logic_hook
    https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_9.0/Architecture/Logic_Hooks/Module_Hooks/after_relationship_add/

    Check if the relationship you just added is between Emails and ModuleA, if so then retrieve the information you need from ModuleA to determine which ModuleB to relate, and add the relationship between ModuleA and ModuleB programmatically. (I know there's a developer manual page somewhere about this but I can't seem to find it - let me know if you need an example)

    FrancescaS

  • Hi Francesca,

    thanks for the reply.

    I'm working on Sugar Prof 8.0

    And your answer was a bit in a different direction.

    To explain it a bit more.

    You can create relations between records (Module A and Module B)

    So in a record in Module A you can search in the Field "Relation to Module B" for the Name of a record in Module B and connect them.

    But i'd like to have a possibility to automatically connect the record from Module B to the record in Module A via an advanced workflow or something like that.

    Maybe more understandable?

    Best,
    L.

  • Sugar Professional does not have Advanced Workflow (called BPM - Business Process Manager - as of version 9.0) and the simple Workflow we have access to will be going away so I suggest you start replacing any workflow with logic hooks.

    I understand that you can relate A and B via the interface.

    If the logic applies every time you save a moduleA record then you can ignore the Email portion and just have a hook on moduleA.

    If your relationship is defined by a Relate Field in ModuleA:

    use a before_save logic hook on ModuleA, check to see if the related id to moduleB already exists, if not, retrieve the appropriate ModuleB (you did not say how that is identified but I assume you have sufficient info in ModuleA to do that) and update ModuleA's related field to record the id of ModuleB.

    If your A-B link is defined by a Relationship:

    use an after_save logic hook (A needs to exist before you can link it to B), retrieve the B record, check to see if the two are already related, and if not link the two programmatically.

    The difference between this and the solution with the Emails module is that this one triggers every time you save the moduleA record regardless of how it's saved. The other only when the ModuleA record is first created by the Email.

    I hope this helps.

    Francesca