Set An Alert on Sharepoint 2013 for multiple list and library - email

I have some sites with many list and library. I want to know about their changes. set alert for any list and library is very difficult and It takes a long time.
Is there any soloution ?

We can use create alert for all the custom list and document library using C# code or PowerShell script.
The following C# code for your reference.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("http://sp2013"))
{
using (SPWeb web = site.OpenWeb())
{
foreach(SPList list in web.Lists)
{
if (list.BaseType == SPBaseType.GenericList || list.BaseType == SPBaseType.DocumentLibrary)
{
SPUser user = web.EnsureUser(#"domain\admin");
SPAlert newAlert = user.Alerts.Add();
newAlert.Title = "My Custom Alert";
newAlert.AlertType = SPAlertType.List;
newAlert.List = list;
newAlert.DeliveryChannels = SPAlertDeliveryChannels.Email;
newAlert.EventType = SPEventType.Add;
newAlert.AlertFrequency = SPAlertFrequency.Immediate;
newAlert.Update();
}
}
}
}
});
Reference:
Programmatically Creating Alerts in SharePoint
Create - Edit - Find - Delete SharePoint Alerts using PowerShell

Related

get value for specific question/item in a Google Form using Google App Script in an on submit event

I have figured out how to run a Google App Script project/function on a form submit using the information at https://developers.google.com/apps-script/guides/triggers/events#form-submit_4.
Once I have e I can call e.response to get a FormResponse object and then call getItemResponses() to get an array of all of the responses.
Without iterating through the array and checking each one, is there a way to find the ItemResponse for a specific question?
I see getResponseForItem(item) but it looks like I have to somehow create an Item first?
Can I some how use e.source to get the Form object and then find the Item by question, without iterating through all of them, so I could get the Item object I can use with getResponseForItem(item)?
This is the code I use to pull the current set of answers into a object, so the most current response for the question Your Name becomes form.yourName which I found to be the easiest way to find responses by question:
function objectifyForm() {
//Makes the form info into an object
var myform = FormApp.getActiveForm();
var formResponses = myform.getResponses()
var currentResponse = formResponses[formResponses.length-1];
var responseArray = currentResponse.getItemResponses()
var form = {};
form.user = currentResponse.getRespondentEmail(); //requires collect email addresses to be turned on or is undefined.
form.timestamp = currentResponse.getTimestamp();
form.formName = myform.getTitle();
for (var i = 0; i < responseArray.length; i++){
var response = responseArray[i].getResponse();
var item = responseArray[i].getItem().getTitle();
var item = camelize(item);
form[item] = response;
}
return form;
}
function camelize(str) {
str = str.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()#\+\?><\[\]\+]/g, '')
return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function(match, index) {
if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces
return index == 0 ? match.toLowerCase() : match.toUpperCase();
});
}
//Use with installable trigger
function onSubmittedForm() {
var form = objectifyForm();
Logger.log(form);
//Put Code here
}
A couple of important things.
If you change the question on the form, you will need to update your
code
Non required questions may or may not have answers, so check if answer exists before you use it
I only use installable triggers, so I know it works with those. Not sure about with simple triggers
You can see the form object by opening the logs, which is useful for finding the object names

SharePoint 2013 REST API - Post SocialRestPostCreationData

I’m currently working on a small application to push Post to a SharePoint 2013 SiteFeed using the Social.Feed API.
Basic Posts using the following JSON Object structure are working fine but I’m struggling using a Social-Attachment.
As long I’m referencing to the files located somewhere in the internet everything works. Posts will create listitems in micro-feed list with HTTP-Reference to the Files. The Object I'm using is set up like this
var creationInfo = new
{
restCreationData = new
{
__metadata = new { type = "SP.Social.SocialRestPostCreationData" },
ID = array,
creationData = new
{
__metadata = new { type = "SP.Social.SocialPostCreationData" },
Attachment = new
{
__metadata = new { type = "SP.Social.SocialAttachment" },
AttachmentKind = 0,
ContentUri = "https://www.google.com/images/icons/hpcg/ribbon-black_68.png",
Description = "Look at this",
Name = "Test",
Uri = "https://www.google.com/images/icons/hpcg/ribbon-black_68.png"
},
ContentText = text,
UpdateStatusText = false,
}
}
};
Is there a possibility to use a local file instead? - Removing the google paths and using a local path in ContentUri will end up in a BAD-Request error.
I guess that the files has to be uploaded somehow before.
Thanks for you help.
Iki
After some trying we now ended up with the following solution.
Before we create the SocialPost, we upload the picture into an image gallery where all Feed users have access to.
Then we create the post containing a link to the image
-> This will do the trick.

Magento2 : How to add multiple product in cart using single form submission?

I am new in magento2 and using version 2.1.
I have to add multiple product in cart, the product can be any type and I want to add ajax validation as well with this functionality.
Can any one has idea to achieve this?
Thanks,
Chandan
Hi I got solution for adding multiple products in cart in for loop:
Please refer below code to implement this functionality in MAGENTO 2
if ($product_id) {
$storeId = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId();
try {
if(isset($params['super_attribute'][$product_id])){
$params_post = array();
$params_post['form_key'] = $this->formKey->getFormKey();
$params_post['qty'] = 1;
$params_post['super_attribute'] = $params['super_attribute'][$product_id];
$finalproduct = $this->productRepository->getById($product_id, false, $storeId);
$this->cart->addProduct($finalproduct, $params_post);
} else {
$params_post = array();
$params_post['form_key'] = $this->formKey->getFormKey();
$params_post['qty'] = 1;
$finalproduct = $this->productRepository->getById($product_id, false, $storeId);
$this->cart->addProduct($finalproduct, $params_post);
}
} catch (NoSuchEntityException $e) {
}
}

Sitecore 7.5 DMS Tracking Goal Programmatically

I'm currently trying to track a button click in sitecore 7.5 using sitecore DMS, i'm finding alot of information on the internet but most of it is pre 7.5 before the change over to MongoDB...
Previously it would look something like this:
//Check that analytics are on...
if (Sitecore.Analytics.Tracker.IsActive && Sitecore.Analytics.Tracker.CurrentPage != null)
{
//Get the item goal.
Item goalItem = Sitecore.Context.Database.GetItem(&quot;{xxxxx-xxx-xxx-xxxxx}&quot;);
//Page event wrapper
PageEventItem goal = new PageEventItem(goalItem);
//Create the record that needs to store the goal
VisitorDataSet.PageEventsRow pageEventsRw = Sitecore.Analytics.Tracker.CurrentPage.Register(goal);
//this is not mandatory
pageEventsRw.Data = "custom text";
Sitecore.Analytics.Tracker.Submit();
}
I want to achieve this kind of goal in Sitecore 7.5 but struggling to find much resource on the internet, wondering if any advanced sitecore users could point me in the right direction?
Cheers,
MW
Can you try :
if (Sitecore.Analytics.Tracker.IsActive && Sitecore.Analytics.Tracker.Current.CurrentPage != null)
{
Sitecore.Data.Items.Item GoaltoTrigger = Sitecore.Context.Database.GetItem("{Item ID of the Goal}");
if (GoaltoTrigger != null)
{
Sitecore.Analytics.Data.Items.PageEventItem registerthegoal = new Sitecore.Analytics.Data.Items.PageEventItem(GoaltoTrigger);
Sitecore.Analytics.Model.PageEventData eventData = Sitecore.Analytics.Tracker.Current.CurrentPage.Register(registerthegoal);
eventData.Data = GoaltoTrigger["Description"];
Sitecore.Analytics.Tracker.Current.Interaction.AcceptModifications();
}
}

redirecting users according to their group or name in Google Sites

I am trying to make a site using Google Sites, and i need a way to know the user name or group and then redirect them to different pages.
Also if you have any Google script that can help, that will be great too, thanks.
This is a very simple answer but it can help.
We just need to get the user ID and compare it to the list of authorized users, if user is in the list then a link is created, if not, a label is created telling the user they need permission.
I don't need more than that for now, but in the future 2 more features can be cool to add:
1- using group names instead of an array with users to be more dynamic. (i don't know how yet)
2- auto redirect user instead of displaying a link. (i think that can be easy)
function doGet() {
var app = UiApp.createApplication();
var arr = new Array(4);
arr[0] = "user_001#company.com";
arr[1] = "user_002#company.com";
arr[2] = "user_003#company.com";
arr[3] = "user_004#company.com";
for (var i = 0; i < arr.length; i++) {
if (Session.getActiveUser().getUserLoginId() == arr[i]){
var label = app.createLabel('User: ' + Session.getActiveUser().getUserLoginId() + ', You have permission :)');//false
var link = app.createAnchor('Here is your link', 'http://www.umich.edu').setId("link").setVisible(true);//false
var flag = 1;
break;
//#####################
} else {
var label = app.createLabel('You need permission :(');//false
var flag = 0;
}
}
app.add(label);
if (flag == 1){app.add(link);}
return app;
}