0

I am trying to send an email to a user based on a column value. For instance, if the list looks like...

+------------------+-----------+
|      owner       |   data    |
+------------------+-----------+
| test@example.com | "hey guy" |
+------------------+-----------+

My goal is if a person adds a row where owner is test2@example.com and data is "wowie", then a workflow would run or a notification would trigger where test2@example.com would receive an email that included the value from data that just got added. How would this be possible?

Note, I don't have access to SharePoint designer and I am working in SharePoint 2010.

Thanks in advance.

1

You could try setting up a situation where you periodically run a script in Microsoft powershell to monitor your list, and check for those certain conditions. I'll provide a little example of what I mean.

SPWeb myWebSite = SPContext.Current.Web;
SPList list = myWebSite.Lists["//name of your list//"]; 
SPQuery query = new SPQuery();

query.Query = "//Query what needs to be found//";
SPListItemCollection myItems = myList.GetItems(query);

foreach(SPListItem item in myItems)
{
    //Your code to get data and send email
}

EDIT: Actually, I just realized you aren't trying to search for something in your list, just email the person the data that they just added. You can achieve this through Jquery on the webpage (since it can all be done client side) whereby you poll Jquery to activate when a user hits a save button or something, grab the data from the fields, and then work with it through Jquery functions. Or you can do this by modifying the previous code example to look something like:

SPWeb myWebSite = SPContext.Current.Web;
SPList list = myWebSite.Lists["//name of your list//"]; 
SPQuery query = new SPQuery();

SPListItemCollection myItems = myList.GetItems(query);

SPListItem item = myItems(list.Count - 1);  //Return the last element in the list
//Your code to grab the info, and then email based on the info

You could then set up the script to execute everytime an item is added to the list, either through Javascript, or some other means.

I hope this helps!

  • Thanks, this does! I don't have much SharePoint experience at all, so would I just use webparts to accomplish this with javascript? What should I Google for useful resources on this? – Milo Gertjejansen Jun 4 '14 at 18:01
  • Yes, essentially. I haven't had as much experience with Javascript as I would like, but you can create a Javascript function like "onbuttonclick" or something, and attach the script to the save button to grab the values from the fields. This will help if you are new to javascript. This shows an example more like what you are doing – Brandon C. Jun 5 '14 at 6:58

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.