Send Email nodes in a process model are not all sending emails. Only one or two are sending emails. Please advise possible causes.

Send Email nodes in a process model are not all sending emails. Only one or two are sending emails. Please advise possible causes.

  Discussion posts and replies are publicly visible

Parents
  • Hi anushas0002,

    Can you please check, Are you working on Appian On-Premise, and have you configured some email Ids or different. If both the answers are yes, then ask the Appian Administrator to configured the new emails/users added.

    Thanks
    Aditya
  • It's not on-premise instance. it is AWS appian cloud instance and OOB mail server provided by Appian.

    Below is the error due to which emails are not sent. Some processes are clearly throwing this error randomly and some processes are not even throwing error and emails are simply not sent. The requestor field does have value "email" which is the username of an user.

    Problem: An invalid expression has been encountered in a task.
    Details: An error occurred while evaluating expression: =user(pv!NSARequest.Requestor,"email") (Expression evaluation error at function 'user': Null argument not allowed) (Data Inputs)
  • 0
    Certified Lead Developer
    in reply to anushas0002

    Hi Anusha,

    You are facing this issue because, pv!NSARequest.Requestor has some null values, if the username is not null and doesn't exist in Appian environment then the expected exception should be: 

    Expression evaluation error at function 'user': Error evaluating function 'user' : [InvalidUserException] whereas when the username is null then this will throw an exception as mentioned by you. Also you cannot have a user Id without their email address, because Email address is a required field in order to create a User in Appian.

    Hence in order to fix this issue, you have multiple ways, 

    1. Remove all the nullable values from pv!NSARequest.Requestor using reject function before fetching their email ID as shown below ( Created a rule to do so):

    load(
      local!users_txt: reject(
        rule!APN_isEmpty(array: _),
        ri!users_txt
      ),
      a!forEach(
        union(local!users_txt, local!users_txt),
        user(
          fv!item,
          "email"
        )
      )
    )
    
    /* Here ri!users_txt is a rule input of type: Text (Array/Multiple) */
    /* Make sure invalid user's are not exist in your input, otherwise this will throw following exception: Error evaluating function 'user' : [InvalidUserException] */

    Here your input to this rule will be: pv!NSARequest.Requestor which is of type Text (Multiple/Array)

     

    2. Alternatively you can Create a rule which will take an input of type Text (Multiple / Array) i.e. pv!NSARequest.Requestor and will return list of email Id's by handling null as shown below:

    load(
      local!users_txt: reject(
        rule!APN_isEmpty(array: _),
        ri!users_txt
      ),
      local!emails_txt: a!forEach(
        local!users_txt,
        if(
          isusernametaken(
            username: fv!item
          ),
          user(fv!item, "email"),
          {}
        )
      ),
      union(local!emails_txt, local!emails_txt)
    )
    
    /* Here ri!users_txt is a rule input of type Text (Array/Multiple) */

    Here isusernametaken() is a custom plugin function available here which checks whether input user exist or not. Your input to this rule will be pv!NSARequest.Requestor (text - Multiple/Array), this will take care of null, {}, "", Invalid user's etc.. 

    NOTE: Once you get list of email id's in Text format, make sure to use toemailaddress() function to convert these emails of type "List of Text String" to "List of Email Address" under "To" property of Send E-Mail smart service where input to this function will be the variable which holds the response of any of these two above code snippet.

    Hope this will help.

  • Thanks Alok for the info. The Requestor is single value and not array. Requestor is an username. not sure if the above work around are required for this scenario. Please see the below mapping in send email node which shows a simple way to get email by username with user function. My concern is why is this function not working as expected despite of passing correct values and there are no null values as shown in below image.

    Problem: An invalid expression has been encountered in a task.
    Details: An error occurred while evaluating expression: =user(pv!NSARequest.Requestor,"email") (Expression evaluation error at function 'user': Null argument not allowed) (Data Inputs)
  • +1
    Certified Lead Developer
    in reply to anushas0002

    Hi Anusha,

    If pv!NSARequest.Requestor is Single variable, then try checking for the Instance which was broken. I believe the value for Requestor attribute/property in pv!NSARequest process variable is null.

    As per my understanding, this node is working as expected, and problem is with you data, where it's sending null to your expression which uses user() function, hence you need to handle the null, {}, "" etc..

    To debug this issue, monitor and edit a process instance which was broken, and replace pv!NSARequest.Requestor with a valid email id (of type Email Address) hard coded and apply changes, restart the node, this will work as expected.

Reply Children
No Data