on 03-05-2014 7:29 PM
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
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
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.