Skip to main content
7-Bedrock
May 19, 2022
Solved

Is any API or customization available to retrieve PLM user email address?

  • May 19, 2022
  • 1 reply
  • 1776 views
I am using Windchill PDMLink Release 11.2 and Datecode with CPS 11.2.0.0

Is any API or customization available to retrieve the PLM user email address to be used to send email notifications?
Email is to be used in customization provided in Article - CS63309.

Or any way to retrieve "DefaultNotificationSenderEmail".
    Best answer by avillanueva

    Do you just need the address? Try this:

    ((WTUser)localWTPrincipal).getEMail()).getAddress();

    1 reply

    avillanueva
    23-Emerald I
    23-Emerald I
    May 19, 2022

    Do you just need the address? Try this:

    ((WTUser)localWTPrincipal).getEMail()).getAddress();

    7-Bedrock
    May 20, 2022

    Thank you @avillanueva for the quick reply.

    As I am using Article - CS63309 to send email notifications, but am not able to receive any emails.

    Does it require any configuration before using the customization provided in the article?

    avillanueva
    23-Emerald I
    23-Emerald I
    May 20, 2022

    This is a snippet I use to create my own workflow task notification email. I know that general email notifications might vary slightly but they all use a template. Does this help? Aside from receiving emails, you can check that the queue is actually creating the notification. If you stop the queue, you can see if it indeed is being queued up to send an email.  If you restart the queue, the task will disappear after its processed and the email should be on its way. Unless there is something outside of the system that is not delivering it. Sry for simple question but have you verified that other emails are being send from system properly and just not these custom ones?

    WTDistributionList distroList = new WTDistributionList();
     Persistable p = null;
     if ((workItem.getPrimaryBusinessObject() != null) && (workItem.getPrimaryBusinessObject().toString() != null))
     p = workItem.getPrimaryBusinessObject().getObject();
     if (AccessControlHelper.manager.hasAccess(user.getPrincipal(), p, AccessPermission.READ)) {
     LOGGER.debug("adding " + user.getDisplayName() + " to distribution.");
     distroList.addPrincipal(user.getPrincipal());
     }
     TemplateEmailNotification email = new TemplateEmailNotification(distroList);
     Object[] arrayOfObject = new Object[5];
     arrayOfObject[0] = activity.getName();
     email.setSubjectResource("wt.workflow.work.workResource");
     email.setSubjectMessageKey("124");
     email.setSubjectInserts(arrayOfObject);
     //PDML-10 - Improved email templates showed call out of template processor was incorrect.
     WfTaskNotificationProcessor processor = new WfTaskNotificationProcessor(workItem);
     //processor.setWorkItem(workItem);
     email.setTemplateProcessor(processor);
     email.setTemplate(TemplateName.getWorkNotification("General"));
     //processor.setState(new TemplateProcessorState());
     String str = "";
     try {
     str=WTProperties.getLocalProperties().getProperty("wt.notify.notificationSenderEmail");
     }
     catch (IOException e) {}
     WTPrincipal localWTPrincipal = activity.getParentProcess().getCreator().getPrincipal();
     if (localWTPrincipal instanceof WTUser) {
     try {
     str = new InternetAddress(((WTUser)localWTPrincipal).getEMail()).getAddress();
     }
     catch (NullPointerException nullE) {}
     catch (Exception e)
     {
     LOGGER.debug("Exception while creating IntenetAddress==>");
     }
     LOGGER.debug("Sender:" + str);
     }
     email.setSender(str);
     LOGGER.debug("Created email, returning.");
     return email;