cancel
Showing results for 
Search instead for 
Did you mean: 

Customizing Notifications - Adding Attributes

former_member2987
Active Contributor
0 Kudos

Hello Experts!

Got a question about working with Notification Templates.  I'd like to be able to add some customized information to a template in the form of a custom attribute.  Is there a way I can do this? The only custom items I seem to be able to add are the "PAR_..." ones.

Thanks!

Matt

Accepted Solutions (1)

Accepted Solutions (1)

bxiv
Active Contributor
0 Kudos
former_member2987
Active Contributor
0 Kudos

Billy, what I'm actually hoping to do is find a way to add my own "PAR" value.

What I think we're going to do is since these are all Context Variables, just "hijack" one using the ones we are not using in the notification via the  uSetContextVar function.  Unless, of course, Former Member has a better idea!

Former Member
0 Kudos

Actually, I think I remember the script just going through every variable and looking for PAR_.

You might be able to just add your own.  If not - its home time in another 3 or so hours ... not that I'm watching the clock

Peter

Former Member
0 Kudos

Which notification script are you working with?

If its the Assignment Notification task with the script named assignmentNotification made for the new approvals then you can just add context variables named #MSG_PAR_<NAME>, and use them in the template file itself you use as PAR_<NAME>. The script uses

ctxVars = uMGetContextVar("#MSG%");

to retrieve all ctx vars starting with #MSG and then loops through all the key/values returned when generating the message

In addition you can set #MSG_TYPE and #MSG_TEMPLATE to use your own templates as well and then trigger the notitication using uProvision outside of assignments. The type/template has to exist in mc_templates though which is easiest accomplished using the job templates provided that read/export templates. I think its been renamed to Notification the next major release because it was designed and implemented to be used for more than just assignments.

If its the pre-sp9 framework (old version) using the sap_core_notificationByEmail script it should be able to replace any attribute that exists on the user/entry object. It gets a list of all the attributes of the entry and then loops through the tpl file to see if its used and if used it gets the value.

Br,

Chris

Message was edited by: Per Krabsetsve

former_member2987
Active Contributor
0 Kudos

Chris,

As usual, this is good stuff. Does this mean there's a place I can declare the ctxvar?  Where would I do this? In the repository? There's none there now. Does that mean that the ones used in the notification script are "built in"?

And no, I'm not using SP9 yet on this project.  Maybe someday...

Thanks,

Matt

Former Member
0 Kudos

Since you asked and I was involved in the development of that notification task thing I thought I'd put together a blog on the topic, but as a quick answer to you:

One solution is to add an action that sets the additional context variables named #MSG_PAR_<something> before the approval task that kicks off the Notification task. Any context variables that exist are inherited by the child task (Assignment Notification in this case). These can be used as PAR_<SOMETHING> in the template file without any other changes:

The Add custom message variables action has a To Generic task that looks like this:

And the script does this:

// Main function: setCTXVARS 

function setCTXVARS(Par){ 

  tmp = Par.get("MSGVARS"); 

  ctxVars = uSplitString(tmp,"!!");  

  for (ctxvar = ctxVars.iterator(); ctxvar.hasNext();dummy=1) 

  { 

  tmp = ctxvar.next(); 

  vals = tmp.split("="); 

  ctxVarToSet = "#MSG_"+vals[0]; 

  ctxValToSet = vals[1]; 

  OutString = uSetContextVar(ctxVarToSet, ctxValToSet); 

  } 

}

As a result I can use something like this in the template file. Just remember to run the job that imports the modifed template file...


Hi PAR_RECIPIENTSDISPLAYNAME

You have an approval waiting in IDM. You should also remember to buy PAR_SHOPPINGLIST on your way home after work.

Also, some important guy said PAR_QOTD

Hope this helps,

Chris

Former Member
0 Kudos

Now summarized in here

former_member2987
Active Contributor
0 Kudos

Thanks, Chris.  Funny how you were working on the issue I needed help with.  Have you taken seeing the future as one of your many hobbies?

M

Former Member
0 Kudos

My stock-market record shows I'm very much blind to the future. I wasn't working on it until you asked here, but as I started setting things up and taking screenshots to answer you here it almost finished itself. Blog-on-demand 🙂

former_member2987
Active Contributor
0 Kudos

The question still remains, who is better than YOU, ?

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Matt

Now you're asking me to dig into the memory banks.  I seem to remember that you could add additional info but the format of the attribute in the task had to be specific.

I'll try and dig up the script library I have when I get home and check it out if you don't get an answer before then.

Peter