Simple Notification Script PX

I’m working from the ground up to make a simple script work, then build on it later, but could use your help with the missing key.  The simple script is this:  every 30 minutes (scheduled event), send notification email to me.

//
import com.agile.agileDSL.ScriptObj.IBaseScriptObj;
import com.agile.agileDSL.ScriptObj.AgileDSLException;
 
void invokeScript(IBaseScriptObj object) {

try {

object.sendNotification(“Notice of Inactivity 2.0 – TEST 5/22”, false,, “Comments: send from Script handler test with test send notification”);

} catch (Exception e) {
object.logMonitor( e.getMessage() );
}
}

However, this script is getting a “No signature of method: com.agile.agileDSL.ScriptObj.BaseScriptObj.sendNotification() is applicable for…” exception/error.

I’ve set up the notification email, the “Notice of Inactivity 2.0 – TEST 5/22”, to notify me directly (the username, not using $NOTIFY) and from $AGILE.  Object type = users (class level).

We need to build on this, but what do you think I’m missing? 
Thank you. 

No Files Were Attached
Matt Paulhus Agile Professional Asked on June 6, 2017 in Product Collaboration.
Add Comment
3 Answer(s)

I have not tried this myself, but I read this in some documentation:

IBaseScriptObj Interface Reference    ( Since: 9.3 )

void sendNotification  ( String  templateName,  
  String  objNumber,  
  int  objClass,  
  boolean  isUrgent,  
  List  recipients,  
  String  comments   
 )   throws AgileDSLException

Send notification.

Parameters:
 templateName  –  the name of the template you would like to send.
 objNumber    –  the objectNumber which you would like to send the notifcation for.
 objClass   –   the object class of the object which you would like to send the notification for.
 isUrgent  –   set to true if the notification is urgent.
 recipients  –  a list of recipients.
 comments  –  comment you would like to send with the notification.  

Exceptions:
 AgileDSLException  if the method fails

mrmathison Agile User Answered on June 7, 2017.
Add Comment

And in the same documentation, it shows different parameters for  IBaseObjectScriptObj
Maybe you could try changing 
      import com.agile.agileDSL.ScriptObj.IBaseScriptObj;    
to   import com.agile.agileDSL.ScriptObj.IBaseObjectScriptObj;

and change

      void invokeScript(IBaseScriptObj object) {
to   void invokeScript(IBaseObjectScriptObj object) {

IBaseObjectScriptObj Interface Reference   ( Since: 9.3 )

void sendNotification  ( String  templateName,  
  boolean  isUrgent,  
  List  recipients,  
  String  comments   
 )   throws AgileDSLException

Send the notification regarding the current object.

This method can’t be invoked in pre create object handler and post delete object handler.

Parameters:
 templateName   –  the name of the template you would like to send.  
 isUrgent   –  set to true if the notification is urgent.  
 recipients  –  a list of recipients.  
 comments  –   comment you would like to send with the notification.  

Exceptions:
 AgileDSLException  if the method fails

mrmathison Agile User Answered on June 7, 2017.
Add Comment

Ok, we figured it out.  Let me just document it here for anyone else. 
We weren’t sure if our import statements were conflicting, so we minimalized that.  But mostly it was the object.  Agile already specifies the object during whatever action is happening (hence why most examples leave it off).  So if your trigger (Event node) is updating the affected items tab of an ECO, Agile will already use that ECO as the Object (part of the sendNotification syntax).  Check the Event Handler Monitor for the Object that is specified. 

As a result, this worked for us:

//

import com.agile.agileDSL.ScriptObj.IBaseScriptObj;

import com.agile.agileDSL.ScriptObj.AgileDSLException;

void invokeScript(IBaseScriptObj object) {

try {

object.sendNotification(“Designs – Test Email”, false, [“userid”], “Comments: send from Script handler test with fake send notification”);

} catch (Exception e) {

object.logMonitor( e.getMessage() );

}

}

Event itself is updating the relationship tab of a Design (subclass).  Note that the Notification email Object type needs to match the notification type in the groovy script. 

I’m looking to now build on this for future use. 

Matt Paulhus Agile Professional Answered on June 9, 2017.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.