Add Flex relate value in calculated formula

Hello Sugar Developers,

I want to add flex relate(parent_name) value in Calculated Formula in Meetings module for subject (Meeting Name) field.

But I don't get field name (parent_name) in formula fields. 

Thanks,

 .

  • Hello Juned,

    I came across your question today while trying to solve a similar issue with the Flex Relate field.

    The formula for related fields is relate($moduleName,"FieldName"), which for you would be relate($accounts,"Updated Name"). But, since meetings uses a FlexRelate your subject will be blank if they are linking the meeting to a contact, lead, opportunity, etc. You cannot use the actual field $parent_name, you have to use a combination of ifElse and not(greaterThan(strlen to figure out what module is linked and return the field data. 

    //Check if the related module is accounts
    ifElse(
        not(
            greaterThan(strlen(related($accounts,"name")),0)
        )
    ,"Not Account",relate($accounts,"Updated Name")

    Since the Related To field can be linked to any module, you would have to nest the ifElse statements to check each module to figure out what is linked and pull the field you want from each module. Here is an example where you can replace "name" as needed.

    ifElse(
        not(
            greaterThan(strlen(related($accounts,"name")),0)
        )
            ,ifElse(
                not(
                    greaterThan(strlen(related($quotes,"name")),0)
                )
                    ,ifElse(
                        not(
                            greaterThan(strlen(related($opportunity,"name")),0)
                        )
                            ,ifElse(
                                not(
                                    greaterThan(strlen(related($contacts,"name")),0)
                                )
                                    ,"Not Linked"
                            ,related($accounts,"name"))
                    ,related($opportunity,"name"))
            ,related($quotes,"name"))
    ,related($accounts,"name"))

    Reminder: Calculated columns do not update automatically. The existing subject fields will only update after being triggered by Edit/Save or tasks/scripts.

    Also, if you use this to pull a drop down value you will need to replace the related statement with something like

    getDropdownValue("industry_dom",related($accounts,"industry"))

    where you have to call out the drop down list name and then the related module and field name containing the drop down list.

    -John