1

I have a requirement when employee birthday is matches with list column Birthdat = Today then employee should receive an email.

I have created list with two columns ,Employee name and Date of Birth

Still I am not receiving email automatically.

Please find the below screenshots for reference and provide me some suggestions or ideas, enter image description hereenter image description here

manually I am able to receive email workflow is completed without any errors.

0

I think, it's better to start workflow through powershell.

  1. Use one action in your WF: Email Durgam, Santhosh
  2. Use powershell script (ps1-file) to query today birthdays items and to start your WF for them. Start it everyday through win scheduler. It may be the following:

    if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) 
    {     
       Add-PSSnapin Microsoft.SharePoint.PowerShell;
    }
    $host.Runspace.ThreadOptions = "ReuseThread";
    
    Start-SPAssignment –Global;
    
    $spWeb = Get-SPWeb -Identity http://your-web-url;
    $spList = $spWeb.Lists.TryGetList("listname"); # your list name
    if ($spList)
    {
        $spQuery = New-Object Microsoft.SharePoint.SPQuery;
        $spQuery.Query = "<Where>                           
                            <Eq>
                                <FieldRef Name='DateOfBirth'/>
                                <Value IncludeTimeValue='FALSE' Type='DateTime'><Today /></Value>
                            </Eq>
                          </Where>";            
        $spListItems = $spList.GetItems($spQuery);
        if ($spListItems.Count -gt 0)
        {             
            $manager = $spWeb.Site.WorkFlowManager;   
            # Name of WF
            $sWorkflowName = "My_reminder"; # place your WF name here
            $assoc = $spList.WorkflowAssociations.GetAssociationByName($sWorkflowName,"en-US");
            $data = $assoc.AssociationData;
            $nexnotifyday = (Get-Date).AddYears(1)
            foreach($spItem in $spListItems)
            {
                $wf = $manager.StartWorkFlow($spItem,$assoc,$data,$true)
                $spItem["DateOfBirth"]=$nextnotifydate;
                $spItem.SystemUpdate();
            }
            $manager.Dispose();
        }
    }
    $spWeb.Dispose();
    
    Stop-SPAssignment –Global;
    
    Remove-PSSnapin Microsoft.SharePoint.PowerShell;
    
  • Can I use the above script for sharepoint2010? – Santhosh Kumar Jun 6 '18 at 10:52
  • @SanthoshKumar: Yes, I used the similar code in SP2010. – AlexZh Jun 6 '18 at 12:33
  • Thank you I will use same if any help require I will let you know – Santhosh Kumar Jun 6 '18 at 13:40
  • Can you please share your email id or social media contact to get in touch with you easily? – Santhosh Kumar Jun 6 '18 at 13:41
0

Since you need to trigger emails automatically, the ideal way to achieve this would be through SharePoint Timer Jobs. Workflows work on triggers from external source, so your solution does not work. As @AlexZh suggested triggering the WF from PS script, that would work too.

  • I will verify and post the updates tomorrow. – Santhosh Kumar Jun 6 '18 at 16:35
0

You can accomplish this through a workflow by creating another column "Next Birthday". When an item is created in your list, set the workflow to start automatically.

  1. Check if "Next Birthday" is Blank
    • Yes: set "Next Birthday" = "Date of Birth"
  2. Loop while "Next Birthday" <= Today (This may require a Workflow Variable: Flag)
    • "Next Birthday" += 1 Year
  3. Pause until "Next Birthday"
  4. Send Email

Then in the Transition, go back to the beginning of this stage.

  • Can I use the Next birthday column is empty or should fill the data with calculated column? – Santhosh Kumar Jun 7 '18 at 8:34
  • The first step is there so that it doesn't start calculating from the wrong day of the year (whatever the default date for SP d/t fields is). It may be possible to achieve this with a calculated column, but I'm not sure how much calculated columns can do with D/T fields. – vanblart Jun 7 '18 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.