locked
A reminder needs to be sent to manager in every 48 hours if the pending request exceeds 25 RRS feed

  • Question

  • A reminder needs to be sent to manager in every 48 hours if the pending request exceeds 25

    We have two column ManagerEmail and Status in the list:

    Now a Email needs to send Email to those manager's after every 48 hours where Status count exceed to 25

    suggest me client side solution.


    Shiv Sharma

    Wednesday, July 22, 2020 10:36 AM

All replies

  • Hi SharePoint User02,

    You can firstly create a list view in the target list to fiter status equal Pending.

    Then create a Console Application to read the ListItem Count in the List View using CSOM:

    Retrieving List Items From A Specific View Using CSOM

    Send mail in SharePoint:

    https://udaraeshan.wordpress.com/2016/12/12/send-email-in-sharepoint-online-using-sharepoint-client-object-model-csom/

    Then trigger the Console Application with Windows Task Scheduler every 48 hours:

    Console Application Using Windows Scheduler

    JavaScript/Jquery code isn't suitable in this situation because it's running in Browser, can't trigger every 48 hours.

    Thanks

    Best Regards


    "SharePoint" forums will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "SharePoint" forums' new home on Microsoft Q&A !

    Thursday, July 23, 2020 2:47 AM
  • Ok forgot 48 hours, i will do that using task scheduler .

    I have two columns :

    1- ManagerEmail- This contains the manager emails 

    2- Status - values saved in this are Pending , Approved , Rejected.

    Requirement : Want to fetch only those manager's emails whose status value pending count is more then 25 )

    As i have to send mail  those manager whose pending  status exceed 25 request. I have mail code but i am confuse in Rest API End Point query for this senario



    Shiv Sharma

    Friday, July 24, 2020 4:54 AM
  • Hello SharePoint User02,

    You can filter ManagerEmail and Staus Column using CAML Query in CSOM and check the filtered Item Count like this:

    ClientContext clientContext = new ClientContext("your site"); 
    Microsoft.SharePoint.Client.List spList = clientContext.Web.Lists.GetByTitle("camltest"); 
    clientContext.Load(spList); 
    clientContext.ExecuteQuery(); 
    
    if (spList != null && spList.ItemCount > 0) 
    {
       Microsoft.SharePoint.Client.CamlQuery camlQuery = new CamlQuery(); 
       camlQuery.ViewXml = 
          @"<View>  
                <Query> 
                   <Where><And><Eq><FieldRef Name='ManagerEmail' /><Value Type='Text'>administrator@contoso.com</Value></Eq><Eq><FieldRef Name='Status' /><Value Type='Choice'>Pending</Value></Eq></And></Where> 
                </Query> 
          </View>";  
    
       ListItemCollection listItems = spList.GetItems(camlQuery); 
       clientContext.Load(listItems); 
       clientContext.ExecuteQuery();
       if(listItems.Count>25)
       {
          //send email action
       }
    }

    You should use CSOM rather than Rest API in this situation as it needs to be triggered with Task Scheduler.

    And if the reply is helpful to your question, you could Mark as answer so that it could help others in the forum :)

    Thanks

    Best Regards


    "SharePoint" forums will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "SharePoint" forums' new home on Microsoft Q&A !

    Friday, July 24, 2020 5:10 AM
  • Here in above query you passed Email ID administrator@consoto.com hardcore. but i want all those managerEmail's  those status Pending count is more then 25.

    I think your code will not work .Please provide me correct code .

     

    Shiv Sharma

    Wednesday, July 29, 2020 3:47 AM
  • Here in above query you passed Email ID administrator@consoto.com hardcore. but i want all those managerEmail's  those status Pending count is more then 25.

    I think your code will not work .Please provide me correct code .

     

    Shiv Sharma

    Hello SharePoint User02,

    If you want all the managerEmail's count which status is Pending, you can use GroupBy the managerEmail field:

    using (ClientContext ctx = new ClientContext ("http://sp/sites/dev"))
                {
                   
                    List list = ctx.Web.Lists.GetByTitle("camltest");
                    string viewXml = "<View><Query><Where><Eq><FieldRef Name='Status' /><Value Type='Choice'>Pending</Value></Eq></Where><GroupBy Collapse='TRUE' GroupLimit='30'><FieldRef Name='ManagerEmail'/></GroupBy></Query><Aggregations Value='On'><FieldRef Name='ManagerEmail' Type='Count'/></Aggregations></View>";
    
    
                    ClientResult<string> groupBy = list.RenderListData(viewXml);
    
                    ctx.ExecuteQuery();
    
                }

    SharePoint ListItems Group By


    "SharePoint" forums will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "SharePoint" forums' new home on Microsoft Q&A !

    Wednesday, July 29, 2020 6:53 AM
  • The above code that you shared me is server side code? as i am looking client side code. Please suggest me client side code

    Shiv Sharma

    Wednesday, July 29, 2020 10:34 AM
  • Hello,

    The above code is CSOM code snippet which can also used in Client side (out of SharePoint).

    If you are looking for front end code, you can find in another thread posted by you:

    https://social.msdn.microsoft.com/Forums/en-US/9a0d1b27-ef4a-47ff-9796-16e3d3e5d844/rest-api-filter-condition?forum=sharepointgeneral

    And in the article below, also specify the front end code, please learn about it:

    https://piyushksingh.com/2016/11/21/retrieve-grouped-listitems-sharepoint/


    "SharePoint" forums will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "SharePoint" forums' new home on Microsoft Q&A !

    Thursday, July 30, 2020 12:36 AM