Message Template Maintenance How can I pass the Current Environment into the subject or body

I just discovered Message Template Maintenance ! Now when we reset the password, I can send a more meaningfull message in french with details on how to proceed to set it.

It is all fine but, I do those resets both in Prod and in Training env. I can add in the subject the word Production in Prod, and in Training the same ..

The problem is when I restore Prod into Training, the template will have Production in it’s subject, since the DB got replaced.

The ideal would be to have the ability to add a dinamic parameter to be added into the template that we can add the environment, name of the user etc…

How can I acheive that? I saw the {0} which is the new temp password… but can I set up more ? via a BPM ? how to proceed then to use it ?

Anyone done this ?

Ideally, being able to add fields the same with a BPM email would be great !

thanks

Pierre

Additionnal notes:

I know I could add a line in my post-restore script to change the info in the Ice.MessageTemplate , but eventually we will go saas and I have read it will not be available to do that… So bpm way might be a more longterm solution unless future versions of Epicor has this ability already (I am currently on 2022.2.40 )

I just looked around, and there is no way to intercept it.

So your options are to reset it yourself and send your own email, or you can do a BPM to do a slight bit of voodoo on the template itself.

You can do a BPM on Ice.BO.UserFile.ResetPassword.
Edit: Epicor doesn’t call this, at least with the facade on (BPM handler)

You can do a BPM on Ice.BO.UserFile.Update.

Put your own replacement string in the template, and replace it there.

Either a one time thing, or every time.

Ohh OK, so the BPM would send the email instead of being from the template ? what is needed to make sure the template is not fired ? For instance, if the env is not PROD, use the bpm email and cancel the use of the template, else it will use the template (or not use another email from bpm…so cancel the template whatever env… ) Or canceling is not possible ?

For BPMs I have a Condition widget that checks the SysCompany.IsLive field to see if it’s true. If so then that’s PROD if not it’s Pilot or other non-PROD version.

Edit: Just need to make unchecking that box in Company Maintenance part of your DB refresh plan.

Hold, one complication.

Fixing now.

Here is my solution.

My message template subject looks like this:

image

The way Kinetic does it `Ice.BO.UserFile.ResetPassword` is not triggered, at least not with the facade active.

It actually triggers off of `Ice.BO.UserFile.Update`

So I did two BPMS.

#Pre-> Ice.BO.UserFile.Update - “ChangeSomeText”

var isClearingPassword = ds.UserFile.Any(x => x.RowMod == "U" && x.ClearPassword == true);

if( !isClearingPassword ) return;

try
{
    var pattern = "{env}";
    
    var env = Session.AppServerURL.Contains("pilot", StringComparison.OrdinalIgnoreCase) ? "Pilot" : "Production";
    
    CallService<Ice.Contracts.MessageTemplateSvcContract>(mts =>
    {
        var msgTemplateTS = mts.GetByID("TemporaryPasswordResetEmail", "enu");
        
        var msgTemplateOrigRow = msgTemplateTS.MessageTemplate.FirstOrDefault();
        
        var beforeModRow = new MessageTemplateRow();
        
        BufferCopy.Copy(msgTemplateOrigRow, beforeModRow);
        
        msgTemplateTS.MessageTemplate.Add(beforeModRow);
        
        //Store for restore
        callContextBpmData.Character01 = msgTemplateOrigRow.Subject;
        callContextBpmData.Checkbox01 = true;
        
        msgTemplateOrigRow.Subject = msgTemplateOrigRow.Subject.Replace(pattern, env);
        msgTemplateOrigRow.RowMod = "U";
        
        mts.Update(ref msgTemplateTS);
    
    });
}
catch(Exception ex)
{
    InfoMessage.Publish(ex.Message);
}

#Post-> Ice.BO.UserFile.Update - “RestoreSomeText”

if( !callContextBpmData.Checkbox01 ) return;

try
{
    CallService<Ice.Contracts.MessageTemplateSvcContract>(mts =>
    {
        var msgTemplateTS = mts.GetByID("TemporaryPasswordResetEmail", "enu");
        
        var msgTemplateOrigRow = msgTemplateTS.MessageTemplate.FirstOrDefault();
        
        var beforeModRow = new MessageTemplateRow();
        
        BufferCopy.Copy(msgTemplateOrigRow, beforeModRow);
        
        msgTemplateTS.MessageTemplate.Add(beforeModRow);
        
        msgTemplateOrigRow.Subject = callContextBpmData.Character01;
        msgTemplateOrigRow.RowMod = "U";
        
        mts.Update(ref msgTemplateTS);
    
    });
}
catch(Exception ex)
{
    InfoMessage.Publish(ex.Message);
}

in the BPM, I noticed there is condition with that purpose:

image

Under the admin console, server management, there is the option “Set as Production” (we never set it… ) but this condition uses this option…

But for me I would need to Remove Production Status when I restore in my 2 other environments…it is not something to be done via a sql script I was told … so manual activity to not forget during restore process…

thanks Kevin for this, I will certainly try !

Pierre