Event firing at item added and item updated in event receiver?

Hi All,
I have created event receiver on item added & item updated on document library.
1) On Item Added i am updating document library Title column with document Name and i have metadata for the file.
2) On Item Updated i am move that file with metadata to another document library.
Now the issue is the event is triggering is twice when an item is added it automatically calls the item updated event
Need to help please...
Thanks
Balaji More

Hi Thanks for reply.
I have also write Workflow on Source doc library for document approval.
In Source doc library i have choice column fields[Status]. Pending,Approved Default is Pending
when approvers approve the task then i want to update Status: pending to Approved in source doc library using workflow it worked but that time i also want to update destination doc library Status column using Item updated Event receiver but not successed.
Following is code on Item Added.
try
using (SPWeb oWeb = properties.OpenWeb())
oWeb.AllowUnsafeUpdates = true;
string UpdateStatus= string.Empty;
UpdateStatus= properties.ListItem["Status"].ToString();
SPFile File = properties.ListItem.File;
SPDocumentLibrary destLib = (SPDocumentLibrary)properties.ListItem.Web.Lists["documents"];
SPFolder mylibrary = oWeb.GetFolder("Temp");
SPFile spfile = mylibrary.Files.Add(File, streamWriter, true);
SPFile newfile = spfile;
SPListItem item = file.Item;
item["Status"] = UpdateStatus;
item.Update();
oWeb.AllowUnsafeUpdates = true;
Catch()
Item Updated when workflow is approved status is changed Pending to Approved
then i have write a following code but status is not updated when workflow is completed
try
using (SPWeb oWeb = properties.OpenWeb())
oWeb.AllowUnsafeUpdates = true;
string UpdateStatus= string.Empty;
SPFile File = properties.ListItem.File;
if (properties.ListItem["Status"] != null)
UpdateStatus = properties.ListItem["Status"].ToString();
SPDocumentLibrary destLib = (SPDocumentLibrary)properties.ListItem.Web.Lists["documents"];
SPFolder mylibrary = oWeb.GetFolder("Temp");
SPFile spfile = mylibrary.Files.Add(File, streamWriter, true);
SPFile newfile = spfile;
SPListItem item = file.Item;
item["Status"] = UpdateStatus;
item.Update();
oWeb.AllowUnsafeUpdates = true;
Catch()
Thanks
Balaji More

Similar Messages

  • Workflow with item type and item key  is in progress. Abort existing workfl

    Dear all,
    I'm using the below code from the submit button event to launch the workflow. The workflow works fine when I submit for the first time, when i try to submit for the second time from the same session it throws me the error as Workflow with item type and item key is in progress. Abort existing workflow.
    Where I am struck,Kindly send me any solution.
    I am using below code in oaf
    public void workflow(OAPageContext pageContext,
    String headerId,
    String empName,
    String userName
    String wfItemType = "XXSample";
    String wfProcess = "XXSample";
    String wfItemKey = headerId;
    OANavigation wfClass = new OANavigation();
    // Create Workflow Process
    wfClass.createProcess(pageContext, wfItemType, wfProcess, wfItemKey);
    System.out.println("Workflow created");
    wfClass.setItemAttrText(pageContext,
    wfItemType,
    wfItemKey,
    "XXHDRID",
    headerId);
    wfClass.setItemAttrText(pageContext,
    wfItemType,
    wfItemKey,
    "XXEMPNAME",
    employeeName);
    wfClass.setItemOwner(pageContext, wfItemType, wfItemKey,username);
    wfClass.startProcess(pageContext, wfItemType, wfProcess, wfItemKey);
    System.out.println("Workflow started");
    Thanks,
    Kumar.

    Item type and item key forms unique record for the workflow session, you cannot have 2 instances of the workflow running for the same header id, in your case. Check if the process exists for the header id. If so, display a warning message without launching another workflow session, else start the workflow process.
    Thanks
    Shree

  • Item text and item note are not transfering from SRM to ECC on to PR

    Hello Expers!!!
    Due to some requirement we added some logic in BBP_CREATE_BE_RQ_NEW to print the used ID of the shopping cart creator on PR under item text requisitioner tab. but after moving these changes to production the item text(Vendor text) and item note(internal note) which are maintained in the shopping cart are not printing on the Purchase requisition under item text and item note tabs. these two texts were printing correctly before moving our changes.
    please suggest me how this item note and item text will print on PR. Is it a standard functionlity in SRM 5.0?
    is this because of move over changes?
    suggest me to resolve the issue....
    thanks in advance...
    Regards,
    CD Reddy

    Dear Poster,
    As no response has been provided to the thread in some time I must assume the issue is resolved, if the question is still valid please create a new thread rephrasing the query and providing as much data as possible to promote response from the community.
    Best Regards,
    SDN SRM Moderation Team

  • Can you explain about Higher-level item category and item usage?

    Hi all
    Can you explain about Higher-level item category and item usage?
    thanks all

    Higher level item category and Item usage are used in the item category determination.
    Let me take an example of Item Category TANN (Free of charge Item)
    Item category Determination: Sales Document type + Item Category Group + Usage + Higher Level Item Category
    TA + NORM + FREE + TAN = TANN
    Higher Level Item category: The category on which this item category is dependent. meaning for TAN , TANN is a free item. Therefor TAN is the higher level item category.
    Item Category Usage: It controls system response during document processing. The line item has an specific usage according to that usage it has to respond. Free for free items, text for text items etc.
    Regards
    AK
    Reward points if helpful

  • Sum of the items issued and items received

    Sir,
    if i want to get all the sum of the items issued and items received wrt mblnr and matnr, what shd i do??
    thanks
    Arun

    Hi
        Look at this code .It retrieves the sum of LABST field for all line lineitems for a given material No in MARD table.
    TYPES : BEGIN OF Type_Mard,
    W_MATNR TYPE MARD-MATNR,
    W_LABST TYPE MARD-LABST,
    END OF Type_MARD.
    data : ITAB_MARD TYPE TABLE OF Type_MARD,
    wa_MARD TYPE Type_MARD.
    SELECT MATNR
    SUM( LABST) INTO TABLE ITAB_MARD
    FROM MARD WHERE MATNR = p_MATNR " parameters
    AND WERKS = P_RESWK .
    Hope youll get an idea
    Thanks
    Viquar Iqbal

  • How to cancel the event in Item Adding and display javascript message and prevent the page from redirecting to the SharePoint Error Page?

    How to cancel the event in Item Adding without going to the SharePoint Error Page?
    Prevent duplicate item in a SharePoint List
    The following Event Handler code will prevent users from creating duplicate value in "Title" field.
    ItemAdding Event Handler
    public override void ItemAdding(SPItemEventProperties properties)
    base.ItemAdding(properties);
    if (properties.ListTitle.Equals("My List"))
    try
    using(SPSite thisSite = new SPSite(properties.WebUrl))
    SPWeb thisWeb = thisSite.OpenWeb();
    SPList list = thisWeb.Lists[properties.ListId];
    SPQuery query = new SPQuery();
    query.Query = @"<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + properties.AfterProperties["Title"] + "</Value></Eq></Where>";
    SPListItemCollection listItem = list.GetItems(query);
    if (listItem.Count > 0)
    properties.Cancel = true;
    properties.ErrorMessage = "Item with this Name already exists. Please create a unique Name.";
    catch (Exception ex)
    PortalLog.LogString("Error occured in event ItemAdding(SPItemEventProperties properties)() @ AAA.BBB.PreventDuplicateItem class. Exception Message:" + ex.Message.ToString());
    throw new SPException("An error occured while processing the My List Feature. Please contact your Portal Administrator");
    Feature.xml
    <?xml version="1.0" encoding="utf-8"?>
    <Feature Id="1c2100ca-bad5-41f5-9707-7bf4edc08383"
    Title="Prevents Duplicate Item"
    Description="Prevents duplicate Name in the "My List" List"
    Version="12.0.0.0"
    Hidden="FALSE"
    Scope="Web"
    DefaultResourceFile="core"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <ElementManifests>
    <ElementManifest Location="elements.xml"/>
    </ElementManifests>
    </Feature>
    Element.xml
    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Receivers ListTemplateId="100">
    <Receiver>
    <Name>AddingEventHandler</Name>
    <Type>ItemAdding</Type>
    <SequenceNumber>10000</SequenceNumber>
    <Assembly>AAA.BBB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8003cf0cbff32406</Assembly>
    <Class>AAA.BBB.PreventDuplicateItem</Class>
    <Data></Data>
    <Filter></Filter>
    </Receiver>
    </Receivers>
    </Elements>
    Below link explains adding the list events.
    http://www.dotnetspark.com/kb/1369-step-by-step-guide-to-list-events-handling.aspx
    Reference link:
    http://msdn.microsoft.com/en-us/library/ms437502(v=office.12).aspx
    http://msdn.microsoft.com/en-us/library/ff713710(v=office.12).aspx
    Amalaraja Fernando,
    SharePoint Architect
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.

    Recommended way for binding the list event handler to the list instance is through feature receivers.
    You need to create a feature file like the below sample
    <?xmlversion="1.0"encoding="utf-8"?>
    <Feature xmlns="http://schemas.microsoft.com/sharepoint/"
    Id="{20FF80BB-83D9-41bc-8FFA-E589067AF783}"
    Title="Installs MyFeatureReceiver"
    Description="Installs MyFeatureReceiver" Hidden="False" Version="1.0.0.0" Scope="Site"
    ReceiverClass="ClassLibrary1.MyFeatureReceiver"
    ReceiverAssembly="ClassLibrary1, Version=1.0.0.0, Culture=neutral,
    PublicKeyToken=6c5894e55cb0f391">
    </Feature>For registering/binding the list event handler to the list instance, use the below sample codeusing System;
    using Microsoft.SharePoint;
    namespace ClassLibrary1
        public class MyFeatureReceiver: SPFeatureReceiver
            public override void FeatureActivated(SPFeatureReceiverProperties properties)
                SPSite siteCollection = properties.Feature.Parent as SPSite;
                SPWeb site = siteCollection.AllWebs["Docs"];
                SPList list = site.Lists["MyList"];
                SPEventReceiverDefinition rd = list.EventReceivers.Add();
                rd.Name = "My Event Receiver";
                rd.Class = "ClassLibrary1.MyListEventReceiver1";
                rd.Assembly = "ClassLibrary1, Version=1.0.0.0, Culture=neutral,
                    PublicKeyToken=6c5894e55cb0f391";
                rd.Data = "My Event Receiver data";
                rd.Type = SPEventReceiverType.FieldAdding;
                rd.Update();
            public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
                SPSite sitecollection = properties.Feature.Parent as SPSite;
                SPWeb site = sitecollection.AllWebs["Docs"];
                SPList list = site.Lists["MyList"];
                foreach (SPEventReceiverDefinition rd in list.EventReceivers)
                    if (rd.Name == "My Event Receiver")
                        rd.Delete();
            public override void FeatureInstalled(SPFeatureReceiverProperties properties)
            public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
    }Reference link: http://msdn.microsoft.com/en-us/library/ff713710(v=office.12).aspxOther ways of registering the list event handlers to the List instance are through code, stsadm commands and content types.
    Amalaraja Fernando,
    SharePoint Architect
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.

  • Outlook Calendar items added and deleted at same time

    I have several repeating calendar items (like birthdays) in my Outlook calendar.  When I sync, I find that some are added (that I thought were there before) but some show as added and deleted at the same time to my blackberry... any ideas what may be causing the confusion?

    I find myself with the same issue, I just wiped my computer and began syncing and installing all programs back into laptop,now i have noticed that outlook does not add the some events in my calender, for instance, birthdays , one thing that i have noticed is that it only syncs items that have my work email, my other 2 emails are not being synced and those are my blackberry and personal emails.
    my syncing preferences are made to go both way sync ... what seems to be the problem 
    thanks 

  • Item Category and item category determination

    Dear Guru's,
    I have BOM for one material. I have done the full cycle from sales order to billing, everything is fine. I have mainatined combination for item catergory determination as OR+ Norm =Taq and ORNormTaq=TAE. and also maintained copy controls.
    The same i have maintained for Consignment porocess.
    Now i am having problem in the cases return delivery,consignment pickup and consignment returns..
    What are the combinations to be maintained.. What are the standard item categories and assignments to be maintained..
    Regards,
    CS

    hello,
    these are very basic question and can solved if you search over the net or ask your instructor to recommend any book.
    coming to your question
    item category determination  in sales document is done via following rule
    sales document typeitem categorygroupusage+higher level item cat=item cat det in sales doc
    OR                              +       NORM                                                              =TAN
    SCHEDULE LINE CAT determination  in ITEM OF A sales document is done via following rule
    item category+mrp type=schedule line category
    TAN               +PD          =CP
    revert if helpful
    Mohit Singh

  • Calendar View: Unable filter Recurring Event by Start/End Time and Group by Recurring Event View

    Hi All,
    I have just found several issues with Calendar View from WSS 3.0:
    Unable to filter by [Start Time] and [End Time]
    I am not sure why these 2 columns doesn't appear in the Filtering column in the View Settings. The workaround found in the internet is to create calculated column for Start Time and and End Time. However, it doesn't work for Recurring Event, the calculated column will show only first recurring event Start Time.
    Unable to use "Group By"
    When I create new view in Calendar using format: "Standard View, with Expanding Recurring Events", there is no option to specify "Group By". Anyone knows how to show all recurring event in List view and grouped by Start Time (or any other column).
    Thank you and apprecate for any idea.

    Hello,
    I got this from a colleague of mine so I can't take credit for it but here might be a possible workaround:
    1. Create two new Columns called Start Filter and End Filter.  Make these columns Calculated Columns with formulas of [Start Time] and [End Time] respectively.  The columns should be of the Date and Time\Date and Time type and should not be displayed on the Default View.
    2. Click Advanced Settings and choose Yes to the question "Allow management of Content Types" in the Content Types section.  Click OK.
    3. Click on the Event Content Type.  Open the two columns created in step 1 and select "hidden" for both of them.  Click OK.
    4. Back at the list settings create a new view or edit an existing view.  When you get to the filter section choose "Show items only when the following is true" and select the following:
    Start Filter
    is less than or equal to
    [Today]
    And
    End Filter
    is greater than or equal to
    [Today]
    5. Click OK to save the view.
    6. Open the List view web part that is displaying the recently changed calendar and change the view to the newly created or newly edited view.  Click Apply, OK.
    -Aseem Nayar
    This posting is provided "AS IS" with no warranties, and confers no rights

  • Item added & item updated events fired twice.

    Hello everyone, 
    I have item added and item updated events and both sends e-mails twice cos they are fired twice. 
    I tried the below method but the problem still continues. Any suggessions?
    base.EventFiringEnabled=false;
    base.EventFiringEnabled=true;
    note: my list is custom list. (not document lib)

    If you have required checkout enabled the events can be triggered twice. See this post for more information and how to bypass it:
    Managing ItemUpdating and ItemUpdated Events Firing Twice in a SharePoint Item Event Receiver

  • ICal sends multiple emails for invites and updates to event attendees - HELP!

    Every time I create or send an event in iCal, it sends multiple emails to each attendee (2-3 duplicate emails) with the same event.  So if I have 3 event invitees, they get 3 emails each.  All the emails are sent from the correct account in Apple Mail, and the calendar itself shows only one email address for each attendee, but for some reason the sent folder shows that each person was emailed 2-3 times.  This is causing quite a problem for work, as any invite I send is clogging up inboxes with duplicate and triplicates for each attendee. 
    When I send a meeting acceptance, it only sends one reply, so I have no idea why it's duplicating or triplicating events when new ones are sent out or udpated by me.  I can't delete my calendar without losing important events from clients or what not, so I'm not sure what to do.
    Also notable:
    I am NOT using iCloud calendars as I needed to create a calendar group and iCloud didn't support that.
    My calendar is syncing to an FTP so that people in my main office can view and download my calendar as needed.
    I am on a brand new (not even 2 mos old) MacBook Pro Retina 2013 model, with OS X 10.8.3
    I am on Calendar 6.0
    I can't change/update events on my calendar from one sub-calendar to another once they are created (though I can edit on my iPhone and resync). This is really annoying and I've posted about this before to no avail (thread here: https://discussions.apple.com/message/21646850#21646850 and here: https://discussions.apple.com/thread/3920017?start=0&tstart=0).
    For now (for this thread) I'd like any help possible in getting my calendar to send just ONE email to meeting attendees when I create and/or update an event.
    Thanks!

    I have the same issue.  Did you get a resolution to this?  Whenever I add a new person to the meeting invite iCal always resends the entire invite...it should just send the invite to newly added participants.

  • Net Value at Header and Item Level

    Guyz
    I have a header condition say ZFRE, which is manual. when I see total at header level it should be added to other components and show the Net Value. But, it shouldn't appear at item level Net value. With standard settings, ZFRE is being distributed to item level and item total is also considering this condition.
    Thanks!
    MAM

    Hi,
    Header conditions apply to all items in the document and are automatically distributed to the items. A header condition can be based on either a percentage or on an absolute amount. If you enter a header condition that is based on a percentage (for example, a discount of 2%) the system automatically applies this percentage to all items in the document. If the header condition is an absolute amount, there are two different ways in which the system can distribute the amount among the items in the document:
    The condition value of a header condition is either
    distributed proportionally among the items or
    the amount entered at header level is duplicated for each item.
    You control the distribution of absolute header conditions in the group price field per condition type. In the standard version, condition type HB00 is marked as a header condition and as group condition. Condition type RB00 is only marked as a header condition.
    You can try with User Exit USEREXIT_XKOMV_ERGAENZEN_MANU
    in RV61AFZB.
    Thanks.
    Krishna.

  • How i Rename Item Code and Description

    Dear All,
    Can you please tell me how i change Item code and item description in sap b1 8.8.

    This can be very annoying.  If there's a typo in the product code, we cannot update it anymore (since there are already transactions with this product) and the item is not displayed in the correct place when the item list is sorted on the item code.  We can start a new product with the correct code and transfer the items in stock to the new product code, but then all the current transactions are still linked with the old/deprecated product.  Very annoying.
    If someone could find a method to rename the item code without losing the linked transactions, this would really be helpful.  Thanks!
    Regards,
    Pieter Verhaeghe

  • Item text and note not transfering to PO from SRM 5.0

    Hi,
    We are in SRM 5.0/ECC 6.0
    We have a requirement to transfer Item text and item note (Item Text/note to be printed on PO) to ECC PO. From SRM 5.0
    These Item note and Item text is available in PO->Iteam->Service->service text and line text.
    Please advice..
    thanks,
    shri

    For similar kind of problem in SRM 7.0 there is SAP note implementation : Note 1424590 - Text mapping from SRM SC to backend purchase requisition.
    can any one give solution for SRM 5.0

  • Item text and note not transfering to PR which is in ECC from SRM 5.0

    Hi,
    We are in SRM 5.0/ECC 6.0
    We have a requirement to transfer Item text and item note (Item Text/note to be printed on PR(T Code ME53n)) to ECC PR. From SRM 5.0
    These Item note and Item text is available in PR->Iteam->Service->service text and line text.
    Item text comes from Internal note and item note from vendor text .
    I posted same question in SRM Form, but as these changes has to be done by ABAPer so I am posting it again here.
    Please advice..
    thanks,
    shri
    Moderator message: no cross-posting, please.
    Edited by: Thomas Zloch on Nov 14, 2011 9:17 AM

    For similar kind of problem in SRM 7.0 there is SAP note implementation : Note 1424590 - Text mapping from SRM SC to backend purchase requisition.
    can any one give solution for SRM 5.0

Maybe you are looking for

  • ¿Why sms and cell calls doesn't work on mac?

    I downloaded iOS 8.1 and have yosemite OS installed in my mac. i have tried to use the calls and sms feature but none of this works. In the calls when i try to call someone a message pops up saying that i must have an iphone and a mac with the same i

  • Applescript to convert PDF to JPEG using Preview?

    I know there's an existing script available on the internet that converts PDFs to JPEGs (it's here: http://macscripter.net/viewtopic.php?id=25350) BUT, for whatever reason, the quality, even when set to 600dpi, is crap. I get better results simply op

  • IPod Touch 3rd Gen IOS 5

    Its so slow, everything crashes except like settings and weather sometimes notes. i cant type anything cause it freezes i need to get this either back to 4.3.5 or have something done.

  • Not getting Summary Email

    In My Ops Insights, I don't seem to have an option to receive summary emails to my organisational email address. If I sign in, there is no tick box under settings to "Receive email notifications of new Azure Operations Insights Alerts".  I'm presumin

  • Game with layers

    Hi, I'm trying to develop a little game. It's a simple 3/4 view (top-down view isometric) car game (quite classic I know). But what I'm looking for is how to add different layers in my game. I mean when the car is under a tree, then the car should di