Post-posting processing of an activity

2 years 5 months ago #326905 by timstohr
Post-posting processing of an activity was created by timstohr
Hi Kyle, how can I make so that in a post processing step I add a title to an activity (that a user put in using the CREATE ACTIVITY HERE field).

The aim is to have an autoaction on OnAfterCreateActivityStream, have as condition "groupjive.group.%.custom.todo" and then somehow add a title in there without loosing the message information (ie what the user has just written).

Here is an idea that just occured to me... we could simply have the above with a Load by and then overwrite it. The problem that I can see is that it will loose all the information regarding the message...

Please Log in to join the conversation.

2 years 5 months ago - 2 years 5 months ago #326906 by krileon
Replied by krileon on topic Post-posting processing of an activity
Don't used stored titles. They will be removed entirely in CB Activity 6.0.0. You can dynamically add titles using the onDisplayStreamActivity trigger. Example as follows.

Global
Triggers: onDisplayStreamActivity
Type: Code
User: Automatic
Access: Everybody
Conditions
Field: Custom > Value
Custom Value: [var1_asset]
Operator: Is REGEX
Value: /groupjive\.group.\d+\.custom\.todo/
Action
Method: PHP
Code:
$variables['var2'] = 'My title here!';
Parameters
References: Variable 2

CB Auto Actions allows for substitutions so you could substitute your field in at the time of title override. var2 is the activity title display that displays next to their name. For the activity message you'd use var3.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

2 years 5 months ago #326909 by timstohr
Replied by timstohr on topic Post-posting processing of an activity
Works absolutely perfectly with one caveat.

I cannot seem to be able to translations of it (or at least I am confused on how to do it). I have tried translating the text directly (has created a group task), I have tried $variables = 'has created a group task' (the variables indicated by translation highlighting) as well as the string indicated by translation highlighting.

Am I doing anything wrong?

Also, that trick with onDisplayStream is AMAZING!

Please Log in to join the conversation.

2 years 5 months ago #326916 by krileon
Replied by krileon on topic Post-posting processing of an activity
You can run your string through CBs language API to translate it or use the language format function to send a string through translations. For language format function you'll need to enable format functions under the Parameters tab and can also find example of that format function there. As for API usage the below example should work.

$variables['var2'] = \CBLib\Language\CBTxt::T( 'My title here!' );

You can also just use a language key like the following.

$variables['var2'] = \CBLib\Language\CBTxt::T( 'LANGUAGE_KEY_HERE' );

You can use both to allow for English fallback. Example as follows.

$variables['var2'] = \CBLib\Language\CBTxt::T( 'LANGUAGE_KEY_HERE', 'My title here!' );

You can use built in language overrides to translate all 3 usages.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: activha

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.752 seconds

Facebook Twitter LinkedIn