<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged macronotification</title>
<link>https://overflow.efficy.io/?qa=tag/macronotification</link>
<description>Powered by Question2Answer</description>
<item>
<title>Efficy 11: customising notifications</title>
<link>https://overflow.efficy.io/?qa=3172/efficy-11-customising-notifications</link>
<description>&lt;p&gt;Hi team,&lt;/p&gt;

&lt;p&gt;Since Efficy 11 we have a new feature called &quot;notifications&quot;. You probably discovered this feature in our Efficy.&lt;/p&gt;

&lt;p&gt;The new build of Efficy 11 (&lt;strong&gt;r12835&lt;/strong&gt;) added the possibility to customise those notifications by adding a parameter &quot;customparams&quot;. You are able to retrieve information passed to this parameter inside the MacroNotifications.txt.&lt;/p&gt;

&lt;p&gt;An example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Serverscripts/customNotifications.js&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var customParams = {
    &quot;special&quot;: &quot;Just some extra information I need in the macro...&quot;,
    &quot;employee&quot;: &quot;Jean Dupont&quot;,
    &quot;ntEntity&quot;: ntRepo,
    &quot;entityKey&quot;: 45
}

Efficy.sendNotification(
    'Your sales turnover has almost reached it's target!', //title
    'Well done $SALES_NAME$! Click on the notifications to have a full overview', //description
    VarArrayOf([2,88]), //users
    JSON.stringify(customParams, null, '  ') //customparams
);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The code above show you how to use server script / workflow code to generate a custom notification and add custom parameters to it.&lt;br&gt;
After you created a notification this one will be loaded for the specific user(s) you chose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Macros/MacroNotificationsCustom.txt&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;NotiItemVars {[
&amp;lt;# var notiItem = notifications[i],
    authors = notiItem.authors,
    entity = notiItem.entity,
    identifiers = notiItem.identifiers,
    fields = notiItem.fields,
    categories = notiItem.categories,
    relations = notiItem.relations,
    securities = notiItem.securities,
    owner = notiItem.owner,
    massupdate = notiItem.massUpdate,
    recurrence = notiItem.recurrence;

/* All the data you passed to the customParams will be available here */
var notiCustom = notiItem.customparams || null;

/* Simulate entities */
if (notiItem.kind === 'information') {
    entity = {&quot;name&quot;:&quot;info&quot;, &quot;label&quot;:&quot;&amp;lt;%GetLabel('Information', context=JS)%&amp;gt;&quot;};
} else if (notiItem.kind === 'password') {
    entity = {&quot;name&quot;:&quot;key&quot;, &quot;label&quot;:&quot;&amp;lt;%GetLabel('Password', context=JS)%&amp;gt;&quot;};
} #&amp;gt;
]}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Having this in your macro gives you all the imaginable possibilities. You could work with a custom type of notifications which calls a different macro template for example. You could create custom actions (like the 'Accept' / 'Decline' for an action).&lt;/p&gt;

&lt;p&gt;If I forgot something or made an error somewhere in my explanation, please let me know.&lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;

&lt;p&gt;Maxime&lt;/p&gt;

&lt;p&gt;Ps.: thanks to the R&amp;amp;D for this feature&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3172/efficy-11-customising-notifications</guid>
<pubDate>Wed, 23 May 2018 11:41:30 +0000</pubDate>
</item>
</channel>
</rss>