Can anyone tell me if this is the correct way to do it.

Certified Associate Developer

  = getdistinctusers(topeople(cons!IP_GRP_ALERTS)),
a!queryRecordType(
  recordType: 'recordType!{3a27d5e6-31ce-4fe1-995f-821c7e573c8a}IP Add Details.fields.{7340349a-5cf6-4b92-a093-9d1d261d7be2}candidateMail',
  fields: 'recordType!{3a27d5e6-31ce-4fe1-995f-821c7e573c8a}IP Add Details.fields.{7340349a-5cf6-4b92-a093-9d1d261d7be2}candidateMail',
  filters: a!queryFilter(
    field: 'recordType!{3a27d5e6-31ce-4fe1-995f-821c7e573c8a}IP Add Details.fields.{7340349a-5cf6-4b92-a093-9d1d261d7be2}candidateMail',
    operator: "=",
    value: true
  ),
  pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500)
).data

I am using the send email smart service and i used the "topeople" function to send the email to the group members first and then again i used the "user()" function to return a specific info from a field. Is this the correct way ?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I see few issues with this expression. There are two outputs here 

    1. from expression getdistinctusers(topeople(cons!IP_GRP_ALERTS)),

    2. from the query record type

    An expression should have one output so you need to concat the results.

    Another issue is your field "candidateMail".  You are filtering to find records where this field has value as true(). The output of this queryrecord() will be true or null only depending on data. It won't return any username or email address. 

    So check the query record expression in a separate expression and tweak it until it returns the data you need here. Secondly put a concat outside the two expressions (getdistinctusers() as well as query record output).

    Also, if you are passing the constant containing group in it you don't need a topeople() function. getdistinctuser will give the expected output. 

  • 0
    Certified Associate Developer
    in reply to Harsha Sharma

    So i am using this code to retrieve the candidate mail from the candidatemail field so that, the email is sent to the mail address mentioned in the candidatemail field. But i think maybe i might've been wrong so do i need to do something else or add any more code because i am not getting any mail for right now.

  • 0
    Certified Lead Developer
    in reply to skzahed_09

    If I understood correctly you have an interface where recruiter selects a candidate. Then you pass the data from interface to process model. 

    In the process model you want to send email to a group as well as the recruiter and selected candidate. Is my understanding correct so far? 

  • 0
    Certified Associate Developer
    in reply to Harsha Sharma

    Actually i have an interface where panel members select the candidate.

    After the panel members click on yes, the status of the candidate will be updated to approved (Just a brief not relevant to the above doubt)

    And at the same time, a mail is supposed to be sent to the recruiter who hired the candidate and also the candidate.

  • 0
    Certified Lead Developer
    in reply to skzahed_09

    Got it! 

    So on click of Yes hope you are doing submit :true() so that process starts. 

    In the process model you can add a script task where you can add code like below and store the output in pv!emailRecipients

    append(getdistinctusers(cons!IP_GRP_ALERTS),
    toemailaddress(pp!initiator), /*This will give the Recruiter's email id*/
    toemiladdress(a!queryRecordType(
      recordType: IP Add Details,
      fields: IP Add Details.candidateMail,
      filters: a!queryFilter(
        field: IP Add Details.candidateId,
        operator: "=",
        value: pv!selectedCandidateId /* Replace this with record field or pv which has the selected candidate Id*/
      ),
      pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500)
    ).data))

    map the pv!emailRecipients in the To field of the Send e-mail node. Try this and let me know if any doubts or errors are there

  • 0
    Certified Associate Developer
    in reply to Harsha Sharma

    Maybe i confused you a little, because in here the panel is the one who will select the candidates and when the panel member selects a candidate, the candidate will be scheduled for an interview which will be notified to the recruiter who is hiring the candidate and also the candidate to prepare for an interview.

    So there is no need to send the mail to the alerts group, we need to retrieve the data from this record table below 

    we need to retrieve the data from the fields candidatemail and recruiterID. so that the mails will be sent to the recruiter who is in charge of the candidate and the candidate.

  • 0
    Certified Lead Developer
    in reply to skzahed_09

    okay...in that case you can adjust wherever you have the send email node before that add the script task and use append(..) to combine all the email addresses of recipients together. You can refer the above code and adjust the fields as per the data you have in process. configuration of using the output of script task in the send email node will be same as described prevously.

  • 0
    Certified Associate Developer
    in reply to Harsha Sharma

    can you please go through the above reply once again as i have just editd it right now and explained it better in the above one.

  • 0
    Certified Lead Developer
    in reply to skzahed_09

    I the table just have recruiter id in it. You will need to get the user's email id  by querying a table I believe.

    If the above record is being passed to the process model then your script task expression can be something like below

    append(
    toemailaddress(pv!record.candidateMail), /*This will give the Recruiter's email id*/
    toemiladdress(a!queryRecordType(
      recordType:Record that stores recruiter's email,
      fields: above record field reference for recruiters email,
      filters: a!queryFilter(
        field:above record field reference for recruiters Id,
        operator: "=",
        value: pv!record.recruiterId /* Replace this with record field or pv which has the selected candidate Id*/
      ),
      pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500)
    ).data))

  • 0
    Certified Associate Developer
    in reply to Harsha Sharma

    this was the code according to the instructions you have suggested above, the code particularly didnt show any error but iam still not getting any email.

    It shows some there are some unreferenced fields.

  • 0
    Certified Lead Developer
    in reply to skzahed_09

    In line 5 just need to mention record name. Remove the field reference there

    also in line 10 in value within queryfilter pass recruiter id using a variable.

    in line 2 your recordtype reference is missing it will look like pv!record[ip add details.candidateMaill] 

    in line 6 field should be the field storing recruiters email. Not the id. 

    I am giving you examples as i dont know the exacy variable names you are using so replace record with the variable name you are using. Dont copy paste everything as is 

  • 0
    Certified Associate Developer
    in reply to Harsha Sharma

    so in the above line10 am i supposed to use a local variable instead of a record type ?

Reply Children