I have a reminder that all employees are going to ...
# ask-stanley-ai
a
I have a reminder that all employees are going to have but they should only see the reminder when their name is populated in an employee list within the record. How can I achieve this using a single reminder?
c
AI generated answer (using internal Slack threads):
Based on the conversations, you can achieve this by creating a SuiteScript that triggers when the employee record is saved. The script should perform a search to check if the employee's name is populated in the employee list within the record. If the name is found, the script should then create a reminder for that employee. Here is a basic example of how you can structure your SuiteScript:
Copy code
javascript
/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */
define(['N/search', 'N/ui/message'],
function(search, message) {
   function afterSubmit(context) {
      var record = context.newRecord;
      var employeeName = record.getValue('custrecord_employee_name');
      
      var employeeSearch = search.create({
         type: 'employee',
         filters: [['custrecord_employee_list', 'contains', employeeName]]
      });
      
      var searchResult = employeeSearch.run().getRange({start: 0, end: 1});
      
      if (searchResult.length > 0) {
         var reminder = message.create({
            type: message.Type.INFORMATION,
            title: 'Reminder',
            message: 'You have a reminder.'
         });
         reminder.show();
      }
   }
   
   return {
      afterSubmit: afterSubmit
   };
});
This script will run after an employee record is saved. It will search the 'custrecord_employee_list' field for the employee's name. If the name is found, it will create a reminder for that employee. Please note that this is a basic example and you may need to adjust it to fit your specific needs. Also, make sure to replace 'custrecord_employee_name' and 'custrecord_employee_list' with your actual field IDs. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.810966
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.808822751
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.806323349
Please provide your feedback on this answer.