Announcement

Collapse
No announcement yet.

Add ability to use @ to include value of fields for stream's parent entity.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Add ability to use @ to include value of fields for stream's parent entity.

    We use the stream a lot and stream mentions is very powerful however it would great if the stream could have access to its parent fields. e.g in when we compose an email we could access the field of the parent entity of the email and it is very useful. i wonder if this could be applied so when a user mention another user they could also provide details e.g mention a user on case stream and add the parentName to the stream or the Case status. it would be something like below:
    PHP Code:
    Hey @admin Please note that the current case for @parentName has been assigned to @assignedUser and its current status is @status 
    So when the email is fired to notify the admin it would include all the details about the post.

    Thanks

  • #2
    Hi rabii,

    As a workaround you can create a Workflow with Note Target Entity, After record created Trigger Type and the following Execute Formula Script Action:
    Code:
    $assignedUserUsername = record\attribute(parentType, parentId, 'assignedUser.userName');
    $parentName = record\attribute(parentType, parentId, 'parentName');
    $parentType = record\attribute(parentType, parentId, 'parentType');
    $parentId = record\attribute(parentType, parentId, 'parentId');
    $status = record\attribute(parentType, parentId, 'status');
    
    post = string\replace(post, '@assignedUser', string\concatenate('@', $assignedUserUsername));
    
    post = string\replace(post, '@parentName', string\concatenate('[', $parentName, '](YOUR_SITE_URL/#', $parentType, '/view/', $parentId, ')'));
    
    post = string\replace(post, '@status', $status);​
    Of course, this formula can be modified in accordance with your needs, as well as set the necessary conditions for the Workflow to work.

    Comment


    • rabii
      rabii commented
      Editing a comment
      Thanks for sharing this. if i apply this formula will it be reflected on the email sent to the user (Mention)? my purpose is to include the fields value like (parent / account / status etc) in the email sent to the user when someone mention them in a post. will this do the trick or do i have to update the template (Mention) ?

  • #3
    rabii,

    The body of the mention email will look like this:

    Click image for larger version

Name:	image.png
Views:	267
Size:	90.1 KB
ID:	89538
    Note that is easy to change the part of text "has been assigned to @test" to "has been assigned to Test Test user".​

    Comment


    • #4
      Thanks for sharing this trick, it does the job for now although still have to check if the @client e.g exist otherwise it will be amended to the post as (@client) if the value doesn't exist in the post. maybe need to use other function to search for the keywords and only if they exist then append them to the post note.

      Comment


      • #5
        rabii,

        You can try using string\contains() and record\exists() functions, for example:

        Code:
        $assignedUserUsername = record\attribute(parentType, parentId, 'assignedUser.userName');
        $parentName = record\attribute(parentType, parentId, 'parentName');
        $parentType = record\attribute(parentType, parentId, 'parentType');
        $parentId = record\attribute(parentType, parentId, 'parentId');
        $status = record\attribute(parentType, parentId, 'status');
        
        ifThen(
        string\contains(post, '@assignedUser') && record\exists('User', 'userName', $assignedUserUsername),
        post = string\replace(post, '@assignedUser', string\concatenate('@', $assignedUserUsername))
        );
        
        post = string\replace(post, '@parentName', string\concatenate('[', $parentName, '](YOUR_SITE_URL/#', $parentType, '/view/', $parentId, ')'));
        
        post = string\replace(post, '@status', $status);

        Comment

        Working...
        X