Error In Displaying Message When There Is An Attachment

I am trying to display an error message in SharePoint 2013. I added the following code
inside my ItemAdding() event receiver to force it to have error:
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.ErrorMessage = "test";
It
works okay, I can see the error message. 
However, when I attach any files, and try again, after saving, the attachment will disappear.
When I attach again, I will get a server error: 
Please advise.

Hi,
According to your post, my understanding is that you wanted to display error message when there is an attachment.
You need to add “properties.Cancel = true;” to your ItemAdding() event receiver.
You can cancel the event using:
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.Cancel = true;
properties.ErrorMessage = "test";
The properties.Cancel determines if the event should be cancelled.  The default is false but once you set it to true it will cancel the event when the current execution ends.
Here is a similar thread for your reference:
http://stackoverflow.com/questions/17828963/custom-error-message-for-event-receiver-in-sharepoint-2010
More information:
http://davehunter.co.uk/2009/03/12/sharepoint-event-receivers-by-example-email-validation/
Best Regards,
Linda Li
Linda Li
TechNet Community Support

Similar Messages

  • How do I restore error message when there's not enough room to sync?

    By default, iTunes displays an error message when there is not enough room on the iPod to store all the files that are scheduled for synchronization.
    This message also has a checkbox for "Do not remind me again" (or something to that effect). The other day, I stupidly checked this box, and now I don't know how to restore the default setting (i.e., to display the error message). Instead, iTunes just silently does nothing -- with no diagnostic -- if it finds that there's not enough room on my iPod to complete a sync.
    Any ideas?

    Right click on your iPod in iTunes and select the Reset Warning option.

  • Prevent save Message when there is an error

    Hi all,
    Please help me out here.
    I want to prevent saving a new Support Desk Message when there is an error in the message.
    Kind regards,
    Remy Piets

    Hey Remy,
    This can be achieved if you are ready to do some coding...
    U need to use implement BADI ORDER_SAVE..
    Within this BADI u can have your business validations done...
    If the Validations fails then you have to raise an exception DO_NOT_SAVE...
    This is satisfy your requirment.....
    Reward for usefull post...
    Regards,
    Anand........

  • Error Invalid Number message when sending text

    Ever since I upgraded to an iPhone 5s I get an Error Invalid Number message when sending a text to a phone number that used to work just fine from my 4s. In fact I can receive a text from this number but when I try to reply to that text I get the error message again.
    I deleted the contact info in case there was something broken there and I'm trying it with just the raw phone number but without any luck. What can I do? It's my boss's number so it's important I fix this problem. All other contacts and texts are working just fine, it's just this one phone, a Samsung galaxy on T-mobile if that helps. 

    I am having the same exact issue with my Nokia Lumia 920 Windows phone. I was texting my son this morning when one text immediately returned a "+1 (112) 161-1611 Error Invalid Number. Please re-send u sing a vlid 10 digit mobile number" message. His contact info looked fine, but I edited it, re-saved it and tried texting again. Same result - except the number reported in the error message showed 2 "1s" in front of his mobile number. I was able to text my wife a couple of times to report this to her and then it happened with her number in exactly the same manner. I am still able to text people I work with - so this leads me to believe it has something to do with phone numbers that have been saved outside of my corporate contact list. I will be monitoring this posting to see if there is a fix.

  • Why im i getting "an unknown error has occurred" message when i sign into the app store

    Im getting "an unknown error has occurred" message when i sign into the app store. I don't have a problem signing into anything else. What could the problem be?

    Were you able to find a solution to this issue? I am also getting the 'an error has occurred' message when trying to download or update any apps on my iPhone. Restarted, updated, re-booted, etc etc, nothing has worked.

  • I've gotten an Error 150:30 message when try to start Elements 8.0 and asked to contact Adobe support. trying to do that led me here.

    I've gotten an Error 150:30 message when try to start Elements 8.0 and asked to contact Adobe support. Trying to do that led me here.
    Can I get some help here?
    Thanks,
    Harry

    Then try the solutions here:
    https://helpx.adobe.com/creative-suite/kb/error-licensing-stopped-windows.html
    I know it says Creative Suite, but PSE is based on the same code so a lot of the same fixes work for both.

  • Displaying a message when there are no results from an XSL Query

    Using MM_XSLTransform.class.php
    I am querying an XML file to produce a list of places whose town name or address match a letter of the alphabet. The letter is passed as a variable in a URL.
    XSL:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <xsl:param name="letter"/>
    <xsl:output method="html" encoding="UTF-8"/>
    <xsl:template match="/">
    <xsl:for-each select="dataroot/CPINFOWEB[Town=starts-with(Town, $letter) or Name=starts-with(Name, $letter)]">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
            <td>
        <a href="detail.php?park={CostCode}"><xsl:value-of select="Name"/></a><br />
              <a href="detail.php?park={CostCode}"><xsl:value-of select="Town"/></a><br />
          <xsl:value-of select="Address"/><br />
          <br />    
          </td>
            </tr>
          </table>
          </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
    Destination PHP file:
    setXML("../regions/CPINFOWEB-mobile.xml"); $mm_xsl->setXSL("list.xsl"); $mm_xsl->addParameter("letter",$_GET['letter']); echo $mm_xsl->Transform(); ?> 
    The result Name and Town are displayed as a URL to link to a "more details" page.
    All works fine, but when there are no results for a letter of the alphabet I obviously get a blank page.
    How do I display a "no results" message instead

    I deleted my original reply because the formatting of the XSL code was messed up by the forum. Here's trying again:
    Your current code creates a new table for each result. The opening and closing <table> tags should be outside the the <for-each> loop. To deal with the possibility of no results being found, use a conditional statement and the count() function like this:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <xsl:param name="letter"/>
    <xsl:output method="html" encoding="UTF-8"/>
    <xsl:template match="/">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <xsl:for-each select="dataroot/CPINFOWEB[Town=starts-with(Town, $letter) or Name=starts-with(Name, $letter)]">
            <tr>
            <td>
        <a href="detail.php?park={CostCode}"><xsl:value-of select="Name"/></a><br />
              <a href="detail.php?park={CostCode}"><xsl:value-of select="Town"/></a><br />
          <xsl:value-of select="Address"/><br />
          <br />    
          </td>
            </tr>
    </xsl:for-each>
    <xsl:if test="count(dataroot/CPINFOWEB/Town) &amp;lt; 1">
        <tr>
        <td>No records found</td>
        </tr>
        </xsl:if>
    </table>
    </xsl:template>
    </xsl:stylesheet>

  • Insufficient disc space error message when there's 100's of gigs available

    APERTURE MESSAGE READS: There is not enough free space on your Aperture Library volume to import the selected itmes. It is estimated that you need at least an additional 7036MB of space.
    My LaCie Raid reads that it has 858gigs avail and that is the volume where the aplibrary is stored.
    Why do I get this message? Is there a in the aperture prefs where a limit has been set? How do I fix this?
    Thanks in advance,
    Gary

    Hiya,
    I have just started to get this message too. I have 200GB free on a 1TB Lacie Hard Drive that is only used for Time Machine and also as my primary Aperture Vault.
    Formatted in Mac OS Extended Journaled.
    I only need to have a few gig free in order to create the new back up...
    It has worked fine for months until a couple of days ago.
    Any answers anybody?
    Cheers Geoff

  • How to display message when no return values in powershell script?

    Hello,
    I have written following command that returns "Failed" timer job titles for previous day :
    $FailedSPTimerJobs = Get-SPTimerJob | % { $_.HistoryEntries } | Where-Object {($_.StartTime -gt $YesterdayStartDateTime) -and ($_.To -lt $YesterdayEndDateTime) -and ($_.Status -eq 'Failed')}| Select JobDefinitionTitle | ConvertTo-Html -Fragment
    ConvertTo-Html -Body "<font color = blue><H4><B>Report </B></H4></font>$FailedSPTimerJobs " -Title "Test Report" -CssUri C:\style.CSS | Out-File "E:\Reports\Test.html"
    However, I need to display Message ( "There are no Failed Jobs recorded") when records are NULL.
    Would you please let me know how can I achieve this ?
    Thanks and Regards,
    Dipti Chhatrapati

    You could just do something like
    if ($FailedSPTimerJobs){ 
    $FailedSPTimerJobs
    = "There are no Failed Jobs recorded"
    should have been 
    if (!$FailedSPTimerJobs){ 
    $FailedSPTimerJobs
    = "There are no Failed Jobs recorded"

  • OS X 10.5 Mail shows unread messages when there are none and get ghost messages

    I have been searching for an ansswer to this delimma, but have found similar issues but none exactly the same.  I run 10.6 server and have mixed network users of 10.6 and 10.5 clients.  One of the users on 10.5 's mail app keeps showing unread messages, but there are no unread messages.  When they click on another mail box in the mail client or another folder the number changes, but ther always seems to be one or two.  The user also gets at least 2 blank e-mails in the mail app.  I have check the users web mail account and there are no blank e-mail messages or spam.  I tried to rebuild the mail box, and have also tried trashing the indexs, and they still get the same message.  Short of creating a new user does anyone have any suggestions?  None of my other users seem to have the same problem, although they do not use mail as much as this one user does..... 

    I get this issue every single day, and it is specifically reproducible. Here is the scenario:
    1) I have two mail accounts configured on my iPhone, one is my work account and is disabled on the phone, the other is my gmail account which is always enabled on my phone
    2) Each morning, when I head into work I enabled my work email account so I can start reading my work emails for the day. This downloads all the new messages from the server and displays them as unread.
    3) I read some of them, but not all of them.
    4) Once I get to my office, I read all of the rest of my new work emails from the Mail app on my MacBook Pro.
    EXPECTED: The messages that are read on the mail app are updated as read messages
    OBSERVED: On my iphone, not all of the messages have their statuses changed to read. Some of them always remain as unread messages
    5) Next, I delete some of the messages read from my computer from the email server altogether.
    EXPECTED: These messages would also appear deleted when using the mail app on my iPhone
    OBSERVED: Not only are the messages not deleted, but they are still listed as unread
    The only way to resolve this each day is for me to select each message and view it for a second to have the unread message indicator removed. I have to turn off the mail account and turn it back on for it to correctly sync with the mail server and correct the mistakes.
    There is clearly a problem within the iPhone mail app with retrieving updates from the mail servers.
    I have an iPhone 4 running iOS 4.2.1 that I purchased in November. Before that, I had an iPhone 3G S and never experienced the issue on my 3G S. My MacBook Pro was used with both devices.

  • Display message when user again trying to respond survey?

    When User Try To Respond Survey Again ,Displaying Some Error message ,but i want to display A User Friendly Message...
    I Read Some Article But Not Found Any Solution Yet,help me
    AKshay Nangare

    Hi,
    According to your description, my understanding is that you want to display a friendly message when user repeat to respond the survey.
    I suggest you can check if the survey count for current log in user exists using JavaScript Client Object Model and Caml Query, if exists, you can alert a window with some friendly message.
    Here is a detailed code demo for your reference:
    http://sharepoint.stackexchange.com/questions/64357/friendly-message-when-user-tries-to-take-the-survey-again
    Thanks
    Best Regards
    Jerry Guo
    TechNet Community Support

  • Why Am I Getting The "Insufficient Space On Device" Message When There's More Than Enough Space?

    I have the HTC Droid Incredible 4G LTE (ICS/4.0). It has 3.63 GB phone storage remaining, and the sd card has 7.35 GB remaining. Forget the sd card. How can my phone, or any phone for that matter, get the error message of "insufficient space on device" when there's more than enough space on the device? Thank you in advance.

    Turn off your phone.
    Hold power - and volume up I believe  It might be down.
    From there you can select recovery and then hold vilume up and tap power to open the menu.
    There should be an option there to clear system cache.

  • Error: Cannot Display Page when Page1 invoke Page2

    In page1 when click Add button will invoke page2.
    Page1 Coding as below :
    pageContext.setForwardURL(Constants.DETAIL_UPDATE_PG,
    null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null,
    null,
    true, // Retain AM
    OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
    OAWebBeanConstants.IGNORE_MESSAGES);
    Parameter pass (in property parameter):
    txnId     ${oa.current.FaoBudgetTransactionId}
    detailId ${oa.current.BudgetDetailId}
    periodId ${oa.current.BudgetPeriodId}
    Page2 ( in processRequest ) Coding as below
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    if (!TransactionUnitHelper.isTransactionUnitInProgress(pageContext,
    Constants.UPDATE_TXN, true)) {
    // if back button is pressed
    am.invokeMethod("rollback");
    TransactionUnitHelper.endTransactionUnit(pageContext, Constants
    .UPDATE_TXN);
    OADialogPage dialogPage = new OADialogPage(NAVIGATION_ERROR);
    pageContext.redirectToDialogPage(dialogPage);
    } else {
    // teth: added if
    String createNew = pageContext.getParameter("createNew");
    if (createNew != null && createNew.equalsIgnoreCase("Y")) {
    OAViewObject masterVo = (OAViewObject) am.findViewObject(
    "FaoBudPeriodsTempVO1");
    if (masterVo == null) {
    throw new OAException("Object FaoBudPeriodsTempVO1 not found.");
    } else {
    String txnId = pageContext.getParameter("txnId");
    String detailId = pageContext.getParameter("detailId");
    String periodId = pageContext.getParameter("periodId");
    When page1 invoke it error as below.
    Error: Cannot Display Page
    You cannot complete this task because you accessed this page using the browser's navigation buttons (the browser Back button, for example).
    To proceed, please select the Home link at the top of the application page to return to the main menu. Then, access this page again using the application's navigation controls (menu, links, and so on) instead of using the browser's navigation controls like Back and Forward.
    Can somebody help me to solve this problem.
    Thank you very much.

    What is the value of Constants.DETAIL_UPDATE_PG ?
    --Shiv                                                                                                                                                                                                       

  • Having problem with 7.1.2 upgrade, mail icon indicates 70 pending messages when there are none

    Recently upgraded to iOS 7.1.2, the mail icon indicate there are 70 pending messages when in fact there are none

    Recently upgraded to iOS 7.1.2, the mail icon indicate there are 70 pending messages when in fact there are none

  • Message indicator shows messages when there are none

    How to correct the envelope indicator at the top of the screen that shows the number of messages to be 3 when the message & email inbox is empty? I have tried shutting the unit down but it still shows 3 messages and there is none. Help, thanks.
    Solved!
    Go to Solution.

    Hello,
    Please open your message icon and press the menu button(left of the trackball) and click saved messages. Are there any messages in there?

Maybe you are looking for

  • How do I get a phone line repaired in 48 hours?

    My parents (in their 80's and one of whome is ill) have been without a phone for 6 days now. I couldn't even speak to them on Christmas day!! It says on the website repairs in 48 hours. No one has informed them of why the phone is still not working d

  • Satellite C850D - keys are not working when trying to log into laptop

    First I would like to say sorry for my lack of computer knowledge. My C850D is only 2 months old, last night it was working perfectly... this morning when I turn it on to type in my password not all the keys would work. I got a little angry and just

  • How to Remove Text From Strings ?

    Hi, The question I have is, in the String that I have Pasted below, how can I remove the first line (>gi|23821530|dbj||SEG_D10989S Bos taurus gene for endothelin receptor) and then use the remainder of the text to Post to a web server? I have tried d

  • Colors in menu have gone away - why?

    Everything is now gray in the menu when I open up my mac home drive in os 10.7.  Why?  Why change a good thing?  Now when I glance over at the menu of 'Favorites', 'Shared' and 'Devices', all the icons a gray and it doesn't help when finding specific

  • Deleting append structure

    hi guru's is there any way to delete the appended structure? i enhanced a structure by appending it. i want know the way how to delete this append structure. the append structure has a field. it is populated by user exit.i have developer accesskey. t