cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Notification on newly created item based on the recipient being in a FVA

ptc-4671250
1-Newbie

Notification on newly created item based on the recipient being in a FVA

I need to send a notification when an item is created against a specific project. the recipient of the email should be the Project Manager of that project and I am using a FVA field to copy the project manager into the newly created item.

I then created a trigger to fire on newly created items and added the advancedemail.js assigning the FVA field to the recipient.

I have tried both a Pre and Post trigger but what seems to happen is the FVA field is not populated until after the trigger has fired therefore sending no email.

Surely the Post event trigger should send the email to the user in the FVA field as suggested.

What am I doing wrong or does anyone have an alternative.

ACCEPTED SOLUTION

Accepted Solutions
mrump
14-Alexandrite
(To:ptc-4671250)

We use the same trigger.

The code looks somehow like this:

....

var reciever = delta.getNewFieldValue("projectmanager_fva");
logDebug(" < projectmanager_fva mail address > = "+ reciever);
if (reciever == null){
config("\n\n The Script dare only run for projectmanager_fva != null! \n\n Tell you Admin to check the Trigger Rule Settings! ");
return;
}

var mailAddress= sb.getUserBean(reciever).getEmailAddress();
if (mailAddress!= null){
logDebug(" send mail to < projectmanager_fva mail address > = "+ mailAddress);
mySendMail(sender, mailAddress, subject.toString(), msg.toString());
}else{
logDebug(" no mail address for user = "+reciever);
}

....

HTH Matthias

View solution in original post

2 REPLIES 2

This really should work with a Post trigger. Perhaps working through the process with a support engineer would help sort this out. I would recommend opening a support case and possibly doing a screen sharing session.

mrump
14-Alexandrite
(To:ptc-4671250)

We use the same trigger.

The code looks somehow like this:

....

var reciever = delta.getNewFieldValue("projectmanager_fva");
logDebug(" < projectmanager_fva mail address > = "+ reciever);
if (reciever == null){
config("\n\n The Script dare only run for projectmanager_fva != null! \n\n Tell you Admin to check the Trigger Rule Settings! ");
return;
}

var mailAddress= sb.getUserBean(reciever).getEmailAddress();
if (mailAddress!= null){
logDebug(" send mail to < projectmanager_fva mail address > = "+ mailAddress);
mySendMail(sender, mailAddress, subject.toString(), msg.toString());
}else{
logDebug(" no mail address for user = "+reciever);
}

....

HTH Matthias

Announcements


Top Tags