Reference to all parent object types from a child object (e.g. Journal.Email)

Version 1

    Details

     

    I want to be able to use an email signature in an email body irrespective of its parent object type (e.g. Incident, Service Request) but based upon certain field values in the parent object.

    At the moment, I am hard-coding the following code into the Email Body for Journal.Email Reply, Reply All and Forward quick actions.

    $("Hi " +
      (if nvl([Incident#.]AlternateContactEmail,  "") != ""
      then [Incident#.][link:AlternateContactLink]FirstName
      else [Incident#.][link:ProfileLink]FirstName) +
      "," + "<br><br><br><br>" + "Regards,<br><br>" + GetGlobal("Signature") +
      "<br><br><br>" + EmailBody)

    I don't think this will work if the Journal.Email object is run from a different object (e.g. Service Request).

    Therefore, how do I change the code so that it runs irrespective of the parent object?

    In other words, the pseudo-code I want to use is as follows. I understand all parent objects must have same fields and relationships for this to work.

    $("Hi " +
      (if nvl([ParentObject#.]AlternateContactEmail,  "") != ""
      then [ParentObject#.][link:AlternateContactLink]FirstName
      else [ParentObject#.][link:ProfileLink]FirstName) +
      "," + "<br><br><br><br>" + "Regards,<br><br>" + GetGlobal("Signature") +
      "<br><br><br>" + EmailBody)

     


    Resolution

     

    There isn't really a 'universal parent' function or expression - you will need to create an IF - THEN - ELSE or CASE - WHEN statement that inserts the appropriate values based on the type of parent object. 

    Here's an example expression for use in an editing rule upon update of Parentlink_Category that checks a lot of possible parent record types and pulls data from them as appropriate. You can use it as a guideline for crafting the expression required for your environment. This sample just inserts Object Name + Record Number + "update" for each type of object; you should replace that with customized text and values as needed. 

    $(if ParentLink_Category == "Incident" && Category == "Outgoing Email" &&
         Subject == ""
      then "Incident# " + [Incident#.]IncidentNumber + " " + [Incident#.]Subject
      else if ParentLink_Category == "Problem" && Category == "Outgoing Email" &&
              Subject == ""
           then "Problem# " + [Problem#.]ProblemNumber + " update"
           else if ParentLink_Category == "Change" && Category == "Outgoing Email" &&
                   Subject == ""
                then "Change# " + [Change#.]ChangeNumber + " update"
                else if ParentLink_Category == "ReleaseProject" &&
                        Category == "Outgoing Email" && Subject == ""
                     then "Release# " + [ReleaseProject#.]ReleaseNumber + " update"
                     else if ParentLink_Category == "FRS_Knowledge.IssueResolution" &&
                             Category == "Outgoing Email" && Subject == ""
                          then "Issue Resolution Knowledge# " +
                               [FRS_Knowledge#IssueResolution.]KnowledgeNumber +
                               " update"
                          else if ParentLink_Category == "FRS_Knowledge.QandA" &&
                                  Category == "Outgoing Email" && Subject == ""
                               then "Q&A Knowledge# " +
                                    [FRS_Knowledge#QandA.]KnowledgeNumber + " update"
                               else if ParentLink_Category == "FRS_Knowledge.Document" &&
                                       Category == "Outgoing Email" && Subject == ""
                                    then "Document Knowledge# " +
                                         [FRS_Knowledge#Document.]KnowledgeNumber +
                                         " update"
                                    else if ParentLink_Category ==
                                            "FRS_Knowledge.ErrorMessage" &&
                                            Category == "Outgoing Email" &&
                                            Subject == ""
                                         then "Error Message Knowledge# " +
                                              [FRS_Knowledge#ErrorMessage.]KnowledgeNumber
                                                 +
                                              " update"
                                         else if ParentLink_Category ==
                                                 "FRS_Knowledge.Patch" &&
                                                 Category == "Outgoing Email" &&
                                                 Subject == ""
                                              then "Patch Knowledge# " +
                                                   [FRS_Knowledge#Patch.]KnowledgeNumber +
                                                   " update"
                                              else if ParentLink_Category ==
                                                      "FRS_Knowledge.Reference" &&
                                                      Category == "Outgoing Email" &&
                                                      Subject == ""
                                                   then "Reference Knowledge# " +
                                                        [FRS_Knowledge#Reference.]KnowledgeNumber
                                                           +
                                                        " update"
                                                   else if ParentLink_Category ==
                                                           "Task.Assignment" &&
                                                           Category ==
                                                           "Outgoing Email" &&
                                                           Subject == ""
                                                        then "Task# " +
                                                             [Task#Assignment.]AssignmentID
                                                                +
                                                             " update"
                                                        else if ParentLink_Category ==
                                                                "FRS_ApprovalVoteTracking" &&
                                                                Category ==
                                                                "Outgoing Email" &&
                                                                Subject == ""
                                                             then "Approval# " +
                                                                  
                                                                    [FRS_ApprovalVoteTracking#.]TrackingID
                                                                     +
                                                                  " update"
                                                             else Subject)

    NOTE: This expression is an example and should be modified for the current environment and tested before being implemented in Production. You may wish to change the text, need to add or remove objects, or add further constraints in order for it to work as expected.