How to fetch related record by formula

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chinas
    Junior Member
    • Feb 2017
    • 8

    How to fetch related record by formula

    Hello. It is quite easy question, but I am doing something wrong.
    Relation: Task -> oportunity (OneToOne Left) -> Oportunity

    the string
    Code:
    findRelatedOne('Task', taskId, 'opportunity');
    don't returns anything as if there are syntax error.

    Please, open my eyes.​
  • victor
    Active Community Member
    • Aug 2022
    • 728

    #2
    chinas,

    In your case (when the One-to-One Left relation is used), opportunityId will be enough. For example:

    Code:
    $test = opportunityId;
    description = $test;​
    Thus, id of the associated opportunity will appear in the description field of the task. This formula must be used in Administration > Entity Manager > Task > Before Save Custom Script > Formula.

    Comment

    • chinas
      Junior Member
      • Feb 2017
      • 8

      #3
      Unfortunatelly your technique don't work as well.
      I am using formula in Workflow functionality of WorkOut entity at AfterCreation Event.
      The target is copying ForeignLink from "Task.opportunity relation record" to "WorkOut.opportunity record".
      So "opportunityId" not exists at the monent.​

      Comment

      • rabii
        Active Community Member
        • Jun 2016
        • 1250

        #4
        Does Task has any relationship with WorkOut entity ? Also what is the relationship between WorkOut and Opportunity ?

        findRelatedOne is destined for has-many and many-to-many relationships

        > Relation: Task -> opportunity (OneToOne Left) -> Opportunity

        If this is your set up definitely there is an opportunityId (Or what is the name you named that relationship)

        JFY there is no such task.opportunity a Task is a child to different entity types amongst them the opportunity so i order to get the opportunity of a task you need to access the parent field.
        Last edited by rabii; 11-16-2023, 10:22 AM.
        Rabii
        Web Dev

        Comment

        Working...