Web event receiver when adding or deleting a SharePoint hosted app

Hi,
Is it possible to start an action when a SharePoint hosted app is added or deleted from a site collection on our SharePoint 2013 farm on premise?
Also for public apps. Therefore, working with ‘App events’ are not an option.
It tried already with a web event receiver: ‘OnSiteCreated’ and ‘WebDeleting’, but this is not working with appweb's.
When I create a normal subsite, the event is fired. When I added an app to the site, the event is not fired.
Regards,
Johan

Hi Johan,
yes you can do that, try the following:
https://msdn.microsoft.com/en-us/library/office/jj220048(v=office.15).aspx#APPRER
https://msdn.microsoft.com/en-us/library/office/jj220052(v=office.15).aspx
Kind Regards,
John Naguib
Technical Consultant/Architect
MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation
Please remember to mark your question as answered if this solves your problem

Similar Messages

  • How to create event receiver when Task is deleted or deleting?

    HI There,
    how can i able to create event receiver for Task deleting and Task deleted in project server 2013
    i am able to create event receiver for project OnCreating but not able to get solution for receiver for Tasks.
    Please help.
    Regards, Kartik Ghodasara Associative Software engineer, Synoverge Tech Pvt. Ltd. Ahmedabad Please vote or mark as answer if it helps...

    It would appear that Tasks are not part of the Project Server Events system.
    http://msdn.microsoft.com/en-us/library/office/microsoft.office.project.server.events_di_pj14mref(v=office.15).aspx
    the closest I can see is Project : Update(ing)ScheduledProject which would imply a change to the schedule
    I know, not much help,
    Thanks, Eric S. Pcubed

  • Get All Values From NewForm.aspx using Event Receiver Item Adding

    HI All,
             I have conditions to check before the insertion of "Calendar Event".For this I am using Item Adding Event Receiver ,When Click on Save button I need to get all the values of Items filled in NewForm.aspx and check
    the condition,If condition satisfies make them insert else show alert info  as"Not Valid",Below is code and error message
    public override void ItemAdding(SPItemEventProperties properties)
                base.ItemAdding(properties);
               string StartTime = properties.AfterProperties["Start Time"].ToString();
               string EndTime = properties.AfterProperties["End Time"].ToString();
    Error
    Object reference not set to an instance of an object.
    Use the New "Keyword to create an object instance
    Can any one help me how can I do it.
    Thanks,
    Quality Communication Provides
    Quality Work.
    http://siddiq-sharepoint2010.blogspot.in/
    Siddiqali Mohammad .

    Hi,
          Have you tried with the code snippet as mentioned below
    string EndDate = Convert.ToString(properties.AfterProperties["EndDate"]);
    string StartDate = Convert.ToString(properties.AfterProperties["EventDate"]);
    If my post is helpful - please click on the green arrow to mark it as answer

  • How to open List when Page loads in SharePoint Hosted App?

    I  want to create an app same like InstantPracticeManager by InstantQuick.
    Now I want to know that in a SharePoint Hosted App How can I show the Whole List in a page. 
    Here I have added one image:
    Here there is one list and there are 4 views of that list.
    Now the App will be like when I load the page It will show like the image above. Now how can we show the list like this in sharepoint hosted app?
    I want the same scenario which is shown in the following blogs:
    http://sp2013.blogspot.in/2012/08/use-list-view-in-sharepoint-2013-apps.html
    and
    http://www.sharepointnutsandbolts.com/2013/08/working-with-web-parts-within.html
    where they add a list to an app
    Can any one suggest me the idea? I am bit confused.
    thanks in advance.

    Hi,
    According to your post, my understanding is that you want to show the different list view in a page in SharePoint Hosted App.
    We can use jQuery and cross-domain library to achieve it.
    The following articles for your reference:
    Adding a Tabbed View to A Web Part Page Using jQueryUI
    http://sympmarc.com/2011/11/09/adding-a-tabbed-view-to-a-web-part-page-using-jqueryui/
    How to: Access SharePoint 2013 data from apps using the cross-domain library
    http://msdn.microsoft.com/en-us/library/office/fp179927(v=office.15).aspx
    SharePoint 2013: Get list items by using the cross-domain library (JSOM)
    http://code.msdn.microsoft.com/office/SharePoint-2013-Get-items-d48150ae/view/SourceCode#content
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • Sharepoint-Hosted App giving FORBIDDEN error when i use REST Api

    Hi,
    I have created a sharepoint hosted app which will create Team site on button click.
    I used REST Api  and  NAPA Tool to develop this app.
    Napa tool gives to things ClientWebpart.aspx and Default.aspx.
    When i run my Default.aspx code is working fine but ClientWebpart.aspx is giving FORBIDDEN error when i am trying to create site.
    Below is the code which i used to create site
    code:
    var hostweburl;
    var appweburl;
    $(document).ready(function () {
    hostweburl= decodeURIComponent(getQueryStringParameter("SPHostUrl"));
    appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
    function createSPWeb() {
    $.ajax(
    url: appweburl +
    "/_api/SP.AppContextSite(@target)/web/webinfos/add?@target='" +
    hostweburl + "'",
    type: "POST",
    data: JSON.stringify(
    'parameters':
    '__metadata': { 'type': 'SP.WebInfoCreationInformation' },
    'Url': 'RestSubWeb',
    'Title': 'RestSubWeb',
    'Description': 'REST created web',
    'Language': 1033,
    'WebTemplate': 'sts#0',
    'UseUniquePermissions': false
    headers: {
    "accept": "application/json;odata=verbose",
    "content-type": "application/json;odata=verbose",
    "X-RequestDigest": $("#__REQUESTDIGEST").val()
    success: successHandler,
    error: errorHandler
    NOTE:This is on sharepoint online.
    Please help
    Regards,
    sudeep

    So in the app you are testing, are you using the FQDN or the NetBIOS name? Bad practice but could you test with both (hard code the absolute URL for testing purposes) then retest your app?
    If you are making a web part based on the new app model this will be an "app part" and probably have the same issues you are experiencing. If this is for something internal rather than a product you are developing to resell then the script editor /
    content editor web part approach could work for you.
    Paul
    Paul Mather | Twitter |
    http://pwmather.wordpress.com | CPS

  • Error when trying to retrieve Document Library in Sharepoint Hosted App using REST

    I have created the following REST request in order to retrieve the root folder of a Document Library added to a Sharepoint Hosted App
    getProductDocumentFolder: function () {
    $.ajax({
    url: _spPageContextInfo.webServerRelativeUrl +
    "/_api/web/GetFolderByServerRelativeUrl('/Lists/ProductDocuments')",
    type: "GET",
    headers: {
    "accept": "application/json;odata=verbose",
    success: function () {
    alert("Success!");
    //REST.Operator.readAll();
    error: function (err) {
    alert("Oops, error!");
    alert(JSON.stringify(err));
    The Document Library was added to the App from the Add > New Item menu in Visual Studio. I selected List and Selected Document Library from the Create a customizable list... dialog. The list is defined as shown in the picture below.
    I get the generic error "Value does not fall within the excepted range".
    I have tried both 
    "/_api/web/GetFolderByServerRelativeUrl('/Lists/ProductDocuments')"
    and
    "/_api/web/GetFolderByServerRelativeUrl('/ProductDocuments')"
    for the Document Library URL both I get the same error in both cases.
    What am I missing here?

    Problem solved. 
    It turns out there should be NO leading '/' in the relative URL despite the example shown in http://msdn.microsoft.com/en-us/library/office/dn292553.aspx#Folders with "/Shared Folder".
    The correct GetFolderByServerRelativeUrl-parameter in my case is 'Lists/Productdocuments'.
    Unsure whether example is wrong or if it applies to other cases than mine.

  • How to redirect to SharePoint hosted app when user lands on site collection

    is it possible to redirect user directly to SharePoint hosted app when he enters to the site collection? Currently
    user have to click on the app to navigate to SharePoint hosted app and I would like them to directly navigate to app without any clicks required.

    <script type="text/javascript" >
    SP.SOD.executeFunc('SP.JS', 'sp.ClientContext', function() {
    var ctx = new SP.ClientContext.get_current();
    var web = ctx.get_web();
    var appInstances = SP.AppCatalog.getAppInstances(ctx, web);
    ctx.load(appInstances);
    ctx.executeQueryAsync(
    function() {
    window.location =
    appInstances.getItemAtIndex(1).get_appWebFullUrl();
    function(sender, args) {
    console.log(JSON.stringify(args));
    </script>

  • SharePoint hosted App that listens and log SharePoint Events

    Basically, what I need, is something that can listen to all events fired in SharePoint and write them to a custom list.
    I was thinking of making this as a SharePoint hosted app because it has to work on SP Online as well.
    The idea is then, to let a provider hosted app read the custom list every x minutes and do it's own logic depending on the events it reads from the custom list.
    So the question is, how do I catch all the events fired in SharePoint and should it be a SharePoint hosted app that does it?
    Any thoughts on how to solve this?
    Thanks.
    Thomas Bomann, simplySo

    Hi,
    According to your description, my understanding is that you want to track all the event fired in SharePoint .
    Listen to the events in SharePoint needs Server side code, see the article below:
    Programming Event Handling in Windows SharePoint Services
    In SharePoint hosted app, it needs to use Client Object Model, so there is no such Client API to meet the requirement.
    More information:
    JavaScript Client Object Model in SharePoint 2013
    Thanks
    Best Regards,
    Jerry Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • SharePoint Hosted App - Creating cascaded drop down on hosted web lists

    Hi,
    I have created an SharePoint Hosted App(Javascript Object Model) that creates lists on the host web.
    I need to put some javascript into new and edit forms in order to create the cascaded drop down effect on 2 lookup fields.
    Can you please give me some advise?
    Regards,
    Marian

    Hope below article should help you
    http://blog.pentalogic.net/2010/11/editing-the-sharepoint-list-item-menu-part-2-using-javascript/
    http://www.getinthesky.com/2014/03/hide-text-field-sharepoint-form-using-jquery/
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/030471b2-d19a-470f-9a9e-0fd8a229138b/how-do-i-create-a-new-item-form-that-allows-to-save-and-continue-editing?forum=sharepointcustomizationlegacy

  • Create SharePoint hosted app when i debug project in IE browser getting error "Operation aborted" .

    Hi all,
    I am create SharePoint hosted app for SharePoint online. When i debugs project in IE browser getting error "Operation aborted".
     Please Suggest appropriate Way.
    Thanks
    Akash Anand 

    This happens sometimes if you are using third party library which IE does not support. Change the default browser of Visual Studio to Google Chrome and try.
    Let us know either it works or not
    Regards
    Khalil Kothia, PMP
    Blog

  • Can't access community members list in event receiver when item is updated in console application

    Hi,
    we attached an event receiver to a list in a community site template. In the ItemUpdated event we access different lists from the site. Everything is working fine when we update a list item in the web frontend logged in as Administrator (application pool
    identity Administrator).
    Updating an list item in a console application running as Administrator triggers the ItemUpdated event and accesses all lists - only the Community Member list can't be accessed.
    SPWeb spWeb = properties.OpenWeb();
    Guid communityMembersListGuid = new Guid("3b56d08b-be6b-408b-a2aa-c08722ad499b");
    SPList communityMembersList = spWeb.Lists[communityMembersListGuid];
    We added the Administrator with full access to the list, run the code with RunWithElevatedPrivileges and initialized the spSite with the account-token of the administrator. Nothing works.
    Any idea?
    Greetings Peter

    Hi,
    Please try to use the following code blow:
    SPWeb spWeb = properties.Web;
    SPList communityMembersList = spWeb.Lists["Community Members"];
    If the issue still exists, I suggest you debug your code and provide the detail error message for further research.
    Best Regards
    Dennis Guo
    TechNet Community Support

  • How to get the original query string in an event receiver when dialogs are enabled

    I have scenario where I am adding a document to a document library which has an external data column on it. My goal for this column is to have it automatically populated with an appropriate value based on original query string to the page. The general
    idea is that I am on a custom page that has various webparts on it including a view of my document library that is context sensative based on the query string, and I want to use that context sensitivity not just to filter the list but also when adding documents.
    I have been searching around for solutions to this problem all day and have gotten this far:
    I have an event receiver attached to my document library that handles the ItemAdded event syncronously (as such I have the new list item available to me). In that event receiver I am able to set the column values as required. Where I am stuck is on getting
    the value from the query string that I need to actually set as the column value.
    Based on:
    http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/8cfcb299-9a55-4139-86ec-0b53b2922a54 and several similar articles/posts I have been able to get the original source Url with the query string I want via the following
    code in my event receiver:
    private HttpContext context;
    public EventReceiver1()
    context = HttpContext.Current;
    public override void ItemAdded(SPItemEventProperties properties)
    var originalQueryString = context.Request.QueryString["Source"];
    // Parse the query string and use the value ...
    The problem is that this solution breaks down if the dialogs are turned on under the advanced settings for the list. The reason the solution fails is because the "Source" query string parameter goes away and is replaced by "IsDlg" set to a value of "1".
    Does anyone know how to get past this hurdle? Any help would be greatly appreciated.

    Hi Stuart,
    The reason I'm looking for "Source" in the query string is because that is something I found to be reliable when the Dialogs are turned off. I've dug around pretty deep in the Request object to see if anything had the data I was looking for and unfortunately
    it doesn't appear to be there. The
    context.Request.QUeryString.ToString()
    returns a rather simple one of:
    List=%7b43ECDCB0-8440-4652-B067-AA20481779D7%7d&RootFolder=&IsDlg=1
    and the
    context.Request.UrlReferrer.Query.ToString()
    has the same value.
    I suspect this is due to the dual step process that takes place in adding an item to a document library where the first modal popup (which I suspect likely has the information I need) gives you the opportunity to browse to your file and then the second
    dialog (maybe this is getting brought up as a result of another request which is now referring back to the original request that brought up the first dialog?) where you edit your properties.
    Thanks for the try though, if you've got anything else I'd love to hear it.

  • When adding or deleting contacts on my iphone, contacts get added or deleted on another iphone as well?!

    So I have an iPhone 4S and my mom has an Iphone 4. Recently we discovered that whenever we add or delete contacts from her or my phone, they get added or deleted in both our iPhones. So for example: When I add a friend to my contacts, it gets added to her contact list as well. When I delete one of my contacts, it gets deleted from her contact list as well! I think it has something to do with having synced her iphone once on my laptop using my itunes but her phone doesn't have my apps, photos, or music so I don't get how this is happening. Does anyone know how to stop this?

    You are logged into icloud on the same account.
    Go to settings>icloud  and either "delete account" (which signs you out of that account on that device) or just turn contacts off
    I would recommend one of you create your own account specifically for use with icloud.
    Again you can access your icloud settings by going to settings>icloud

  • Error when adding csv file to sharepoint doc library

    HELLO,
    I have an issue when adding file csv to doc library and i didint understand why
    private bool backUPDailyLogs(SPWeb web)
    try
    StringBuilder strCSV = GetStatistiques(web);
    SPFolder myLibrary = web.Folders[ListNames.LogLibrary];
    string fileName = "";
    //Génération du nom de fichier
    fileName = "TRACE_" + DateTime.Now.AddDays(-1).ToString("yyyyMMdd") + ".csv";
    byte[] contents = Encoding.GetEncoding(1252).GetBytes(strCSV.ToString());
    if (contents.Length > 0)
    SPFile spfilelog = myLibrary.Files.Add(fileName, contents, true);
    spfilelog.Item[FieldNames.LogLibrary.Periodicite] = GlobalConstants.Periodicite.Journaliere;
    spfilelog.Item.Update();
    return true;
    catch (Exception ex)
    //Dans le cas ou une éxception est levèe on change la valeur du flag pour intérompre l'éxecution du job pour éviter une perte de données
    // Enregistrer l'erreur dans les ULS et alerter l'admin de l'erreur
    GlobalTools.alertAdmin(" Une erreur s'est produite lors de consolidation des traces de statistiques", ex);
    Log.LogString(LogCategories.Job.Statistiques, ex);
    return false;
    and the error is :
    Message : Impossible d'ouvrir le fichier "http://WebSite/LogLibrary/TRACE_20140811.csv". StackTrace : à Microsoft.SharePoint.
    SPFileCollection.AddStreamOrBytesInternal(String urlOfFile, Stream file, PutFileOpt fileOpt, String createdBy, String modifiedBy, Int32 createdByID, Int32 modifiedByID, DateTime timeCreated, DateTime timeLastModified, Object varProperties,
    String checkInComment, Stream formatMetadata, String lockIdMatch, String etagToMatch, SPLockType lockType, String lockId, TimeSpan lockTimeout, Boolean validateRequiredFields, SPVirusCheckStatus& virusCheckStatus, String& virusCheckMessage, String&
    etagNew, Boolean& ignoredRequiredProps) à Microsoft.SharePoint.SPFileCollection.Add(String urlOfFile, Byte[] file, Boolean overwrite, String checkInComment, Boolean checkRequiredFields) à Microsoft.SharePoint.SPFileCollection.Add(String urlOfFile,
    Byte[] file, Boolean overwrite) à StatistiquesJob.backUPDailyLogs(SPWeb web)
    Any Help will be great :)
    Thanks

    Any help please...

  • Application installation when adding an additional RD Session Host to a collection

    I am in the process of adding a second RD session host to a collection in my Windows Server 2012 R2 RDS deployment. When doing this should I install the applications I wish to publish as remoteapps before adding the host to the collection or after?
    There doesn't appear to be a way to add the RD session host role before adding the host to the collection.
    I am concerned that if I install the applications before adding to the collection, the server may not install them in 'change user /install' mode. However if I install them afterwards, users may be load balanced to the new RD Session host before the
    applications are installed.
    I was just wondering what procedures others use when adding additional RD session host servers to existing collections?
    Thanks

    Hi,
    First you install RD Session Host on the new server, then applications, then add it to collection.  You can install RDSH via Server Manager -- RDS -- Overview -- Deployment Servers -- Tasks -- Add RD Session Host Servers.
    -TP

Maybe you are looking for

  • HELP: How do I add a "DOWNLOADS" folder to the dock on my wife's account?

    Hi, My Leopard has 2 accounts... Mine which is administrator and my wife's which is a user account. For some reason there is no "Downloads" folder on her Dock so when she downloads a file she has trouble finding it. How do I add things to her dock...

  • I have Tiger. Can I install Lion on an external drive?

    I have an iMac Intel Core 2 Duo running Tiger. What I would like to do is install Lion on an external hard drive and have the ability to boot up using either Tiger or Lion as the occasion arises. Reason being, I have some software apps that would no

  • What is the mystery button?

    Greetings- There is a button located on the side of my iMac G3 all in one; it is next to the reset button. Every manual that I have looked at has not identified this button. Does anyone know what the function of this button is? My computer has died..

  • Sizing for IDES ECC 6.0 on Windows/Oracle

    Is there any guideline for sizing a server(Memory and Disk space)to install an IDES system ? The version I am looking for is ECC 6.0 on a Windows/Oracle platform. What if its on Windows/MSSQL ?

  • Can someone explain what all the Virtualbox modules do?

    I see these modules: vboxdrv, vboxguest, vboxnetadp, vboxnetflt, vboxpci, vboxsf, and vboxvideo I know vboxdrv is required, obviously, but I'm having trouble finding documentation about the other modules. vboxnetflt and vboxnetadp are obviously netwo