How to Update multiple items in other list using event handler?

Hi All,
If i update a item in a list, then i should update multiple items in another list need to be update. How to achive using event receivers?

Hi Sam,
According to your description, my understanding is that you want to update multiple items in another list when updated a list item.
In the event receiver, you can update the multiple item using Client Object Model.
Here is a code snippet for your reference:
public override void ItemUpdated(SPItemEventProperties properties)
string siteUrl = "http://sp2013sps/sites/test/";
ClientContext clientContext = new ClientContext(siteUrl);
List oList = clientContext.Web.Lists.GetByTitle("another list name");
ListItem oListItem = oList.GetItemById(1);
oListItem["Title"] = "Hello World Updated!";
oListItem.Update();
clientContext.ExecuteQuery();
Best regards,<o:p></o:p>
Zhengyu Guo
Zhengyu Guo
TechNet Community Support

Similar Messages

  • How to update multiple rows in one query using php

    i am new to this can any one help me how to update multiple rows at a time i am doing an school attendance page

    Often the situation is such that you have multiple courses across a range of dates.So students may take more than one course, and you need to track attendance for each course date. The following graphic demonstrates this:
    In such a situation, you need four database tables as follows:
    students (student_id, student_name, etc.)
    courses (course_id, course_name, etc.)
    students_courses (student_id, course_id)
    attendance (student_id, course_id, dater)
    A fifth table may also be needed to define the dates of courses, but you may also be able to build this array programmatically by using PHP's robust date functions, which can give you, for instance, all the Tuesdays and Thursdays between a start date and end date.
    The students_courses table simply keeps track of which students are taking which courses, so it has just two columns for the primary keys of both of the main tables. The attendance table is similar, but it also includes a date field. The following view of the attendance table demonstrates this:
    So if David's solution does cover your needs, consider yourself lucky, because this could quickly grow from a beginner-appropriate project to a moderately advanced one.

  • How to update multiple records in the table using POST parameters:

    i got this idea from this website:http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-s ingle-sql-query/comment-page-1/#comment-5409. Basically i am trying to update all the status in the results page, and by adding $i in front of the id in the text fields, and checkboxes, i can name the different inputs with different names:
    The image of how it takes the inputs is shown here:http://forums.adobe.com/thread/709034?tstart=0
    I tried this but got this error:Parse error: syntax error, unexpected T_IF, expecting ')' in C:\xampp\htdocs\Database Query\results_change.php on line 51
    will not work in the update code section:
    for($i=0;$i<$maxRows_Recordset1;$i++)
    {$a=sprintf("%s",GetSQLValueString($_POST['changeid $i'],"int"));
    $b=sprintf("%s",GetSQLValueString($_POST['checkbox $i'],"text"));
    $display_order .= array(
        $a => $b
    if($i<$maxRows_Recordset1-1)
    $ids = implode(',', array_keys($display_order));
    $updateSQL = "UPDATE `change` SET Status = CASE Change_id ";
    foreach ($display_order as $a => $b) {
        $updateSQL .= sprintf("WHEN %d THEN %s ", $a,$b);
    $updateSQL .= sprintf("END WHERE `Change_id` IN ($ids)");

    Hi,
    Try
    BEGIN
      FOR i IN 1..APEX_APPLICATION.G_F03.COUNT LOOP
        UPDATE xx_test
        SET checkbox = 'Y'
        WHERE rec_no = APEX_APPLICATION.G_F03(i);
      END LOOP;
    END;Code loops all checked checkbox. You do not need commit on page process.
    Regards,
    Jari
    http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0

  • How to update multiple records in a table using procedure?

    Dear All,
    1 am using 11.1.2.1.0
    my question is i have a table like
    emp id(primary key), empname,location
    1                             damby      blore
    2                             rocky       kormangala
    3                              biswa     india
    my question  is i need to write one procure that at a time i can update empname and location(wat the value are there in empname and location i  need to change at a time).
    thanks
    Damby

    Hi, Damby,
    That sounds like what the UPDATE statement does, exactly.  Just use an UPDATE statement to change any number of columns in existing rows.  You don't need a procedure, but, if you're using a procedure for some other reason, you can do the UPDATE in the procedure.  UPDATE works the same in SQL or PL/SQL.
    Sometimes MERGE is more convenient than UPDATE.  Like UPDATE, it can change any number of columns, either in SQL or PL/SQL.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to update multiple columns from different tables using cursor.

    Hi,
    i have two tables test1 and test2. i want to udpate the column(DEPT_DSCR) of both the tables TEST1 and TEST2 using select for update and current of...using cursor.
    I have a code written as follows :
    DECLARE
    v_mydept1 TEST1.DEPT_CD%TYPE;
    v_mydept2 TEST2.DEPT_CD%TYPE;
    CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
    BEGIN
    OPEN C1;
         LOOP
              FETCH C1 INTO v_mydept1,v_mydept2;
              EXIT WHEN C1%NOTFOUND;
              UPDATE TEST2 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
              UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
         END LOOP;
         COMMIT;
    END;
    The above code when run says that it runs successfully. But it does not updates the desired columns[DEPT_DSCR].
    It only works when we want to update single or multiple columns of same table...i.e. by providing these columns after "FOR UPDATE OF"
    I am not sure what is the exact problem when we want to update multiple columns of different tables.
    Can anyone help me on this ?

    oops my mistake.....typo mistake...it should have been as follows --
    UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
    UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
    Now here is the upated PL/SQL code where we are trying to update columns of different tables --
    DECLARE
    v_mydept1 TEST1.DEPT_CD%TYPE;
    v_mydept2 TEST2.DEPT_CD%TYPE;
    CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
    BEGIN
    OPEN C1;
    LOOP
    FETCH C1 INTO v_mydept1,v_mydept2;
    EXIT WHEN C1%NOTFOUND;
    UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
    UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
    END LOOP;
    COMMIT;
    END;
    Please let us know why it is not updating by using using CURRENT OF

  • How to update Column value in a list using powershell.

    Hi All,
    I am trying to copy value of One column to another column in same list. I am using SPSiteDataQuery for this. I am using following power shell script.
    if ((Get-PSSnapin -Name Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue) -eq $null )
        Add-PSSnapin Microsoft.SharePoint.Powershell
     $CopyFromColumnName1 = "Section-1 Summary" #column copy source 1
     $CopyToColumnName1 = "RichTextBoxControl"  #destination column 1
    $siteCollectionUrl = http://someURL
    $site =new-object Microsoft.SharePoint.SPSite($siteCollectionUrl)
    $query = new-object Microsoft.SharePoint.SPSiteDataQuery
    $query.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='PublishingPageLayout' /><FieldRef Name='FileLeafRef' /><FieldRef Name='RTC' /><FieldRef Name='SummaryOne' />";
    $query.Webs = "<Webs Scope='SiteCollection'>"
    $query.Lists = "<Lists ServerTemplate='850'/>"
    $query.Query = "<Where>
                        <Contains>
                            <FieldRef Name='PublishingPageLayout' />
                            <Value Type='URL'>SomePageLayout</Value>
                        </Contains>
                    </Where>"
    $spListItems = $site.rootweb.GetSiteData($query)
    #Write-Host $spListItems
    foreach($row in $spListItems.Rows)
      $row.RTC = $row.SummaryOne
      write-Host $row.RTC
      $childWeb.Dispose()
    $site.Dispose()
    Here the column RTC is not updating on executing the script. I want to copy data from "SummaryOne" to "RTC" column.
    Please assist me with this issue.
    amol

    Hi Bruno,
    Thanks for reply I use following script and it is working for me.
    if ((Get-PSSnapin
    -Name Microsoft.SharePoint.Powershell
    -ErrorAction SilentlyContinue)
    -eq $null )
    Add-PSSnapin
    Microsoft.SharePoint.Powershell
    #Use the Display Names
    $webApplicationURL
    = Read-Host
    'Provide Site collection/Contnt HUB URL'
    $webApp
    = Get-SPWebApplication
    $webApplicationURL
    $CopyFromColumnName1
    = "colName"
    #column copy source 1
    $CopyToColumnName1
    = "coltoCopyVal" 
    #destination column 1
    if($webApp
    -ne $null)
    foreach($siteCollectionUrl
    in $webApp.Sites)
    $site =new-object
    Microsoft.SharePoint.SPSite($siteCollectionUrl.Url)
    $query =
    new-object Microsoft.SharePoint.SPSiteDataQuery
    $query.ViewFields
    = "<FieldRef Name='Title' /><FieldRef Name='PublishingPageLayout' /><FieldRef Name='FileLeafRef' /><FieldRef Name='RTC' /><FieldRef Name=’Name’ />";
    $query.Webs
    = "<Webs Scope='SiteCollection'>"
    $query.Lists
    = "<Lists ServerTemplate='850'/>"
    $query.Query
    = "<Where>
    <Contains>
           <FieldRef Name='PublishingPageLayout' />
    <Value Type='URL'>PageLayout</Value>
    </Contains>
    </Where>"
    $spListItems
    = $site.rootweb.GetSiteData($query)
    #Write-Host $spListItems
    foreach($row
    in $spListItems.Rows)
    $listId
    = $row["ListId"]
    $webId =
    $row["WebId"]
    $childWeb
    = $site.OpenWeb([GUID]($webId))
    $pagesList
    = $childWeb.Lists[[GUID]($listId)];
    $itemUrl
    = $childWeb.Url
    + "/"
    + $pagesList.RootFolder.Url
    + "/"
    + $row['FileLeafRef'].Split(';#')[2]
    $listItme
    = $pagesList.GetItemById($row.ID)
    $listItme['RTC']
    = $listItme[Name']
    [Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges({
    $listItme.SystemUpdate()
    $childWeb.Dispose()
    $site.Dispose()
    else
    Echo $webApplicationURL
    "does not exist, check the WebApplication name"
    Regards
    Amol
    amol

  • How to update multiple records in custom table using checkbox in APEX 4.1?

    Hi,
    I have a SQL report which brings up all the data records using the following query.
    select
    "REC_NO" AS hidden_rec_no,
    "REC_NO",
    APEX_ITEM.CHECKBOX (3,rec_no) AS edit,
    "MEETING_TYPE",
    "PAGE_NO",
    "CHECKBOX"
    from "XX_TEST" m
    WHERE page_no = :p_page_no
    Out of all records, any records which are checked, I only want to update their flag to 'Y' on the database column "Checkbox". For this, I have a SUBMIT button on the report region. The processing code on pressing the SUBMIT button is:
    DECLARE.
    l_row NUMBER := 1;
    BEGIN
    FOR i IN 1..APEX_APPLICATION.G_F03.COUNT
    LOOP
    FOR j IN l_row..APEX_APPLICATION.G_F01.COUNT
    LOOP
    IF APEX_APPLICATION.G_F01(j) = APEX_APPLICATION.G_F03(i) THEN
    UPDATE xx_test
    SET checkbox = 'Y', -- APEX_APPLICATION.G_F03(j)
    WHERE rec_no = APEX_APPLICATION.G_F03(i);
    l_row := j + 1;
    EXIT;
    END IF;
    END LOOP;
    END LOOP;
    COMMIT;
    END;
    However, that is not happening. Please help me with this. Any solutions/suggestions are most welcome.
    Regards.

    Hi,
    Try
    BEGIN
      FOR i IN 1..APEX_APPLICATION.G_F03.COUNT LOOP
        UPDATE xx_test
        SET checkbox = 'Y'
        WHERE rec_no = APEX_APPLICATION.G_F03(i);
      END LOOP;
    END;Code loops all checked checkbox. You do not need commit on page process.
    Regards,
    Jari
    http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0

  • Workflow - how to update multiple list items

    Is it possible to update up to 3 list items with the same information using a workflow?  My scenario is where a company vehicle (registration number) has up to three drivers assigned to it - Driver Name 1, Driver Name 2 and Driver Name 3.   I
    have two separate lists - one for vehicles (fleet list) and one for drivers (driver database).  In my workflow when an item is created or changed in the fleet list, I would like the current vehicle registration to be updated in all three driver records
    in the driver database.  I am not sure if I can do this as I am unsure of what my unique look up would be as I need to be able to tie a vehicle registration to a driver name. Any advice would be much appreciated.
    Thanks

    Hi,
    Refer to the following threads about how to update multiple list items simultaneously.
    http://social.technet.microsoft.com/Forums/en-US/936d05ba-6e86-4f44-bbdb-b3c5c12b2c68/how-do-i-update-multiple-list-items-at-once-in-a-sharepoint-list
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/2d342b01-1978-40c9-a203-303d145b331e/how-to-update-mulitple-list-items-at-same-time
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/8d5b7424-58dc-470b-8142-90755dbdeaae/sharepoint-workflow-change-multiple-items-in-other-list
    Thanks.
    Tracy Cai
    TechNet Community Support

  • Spark list: how to unselect multiple items programmatically?

    Hi, I have a spark list with multiple selection allowed. I want to add a button next to the list with which to deselect all selected items. How do I go about that? I tried to set myList.selectedItems = null, and myList.selectedItems = new Vector.<Object>, but to no avail. Help would be very much appreciated!

    Hi Sam,
    According to your description, my understanding is that you want to update multiple items in another list when updated a list item.
    In the event receiver, you can update the multiple item using Client Object Model.
    Here is a code snippet for your reference:
    public override void ItemUpdated(SPItemEventProperties properties)
    string siteUrl = "http://sp2013sps/sites/test/";
    ClientContext clientContext = new ClientContext(siteUrl);
    List oList = clientContext.Web.Lists.GetByTitle("another list name");
    ListItem oListItem = oList.GetItemById(1);
    oListItem["Title"] = "Hello World Updated!";
    oListItem.Update();
    clientContext.ExecuteQuery();
    Best regards,<o:p></o:p>
    Zhengyu Guo
    Zhengyu Guo
    TechNet Community Support

  • How to select multiple items when on safari?  Ex: when I have to choose countries where I have worked from a list.

    Hi Everyone
    Please advise: how do I select multiple items when on Safari? Ex. when I have to select multiple countries where I have worked.

    Hi Carolyn
    I am trying to select multiple items from a list on a particular website. I tried using the 'command' button, but to no avail.
    Grateful for any advice.

  • How to select Multiple items in the dvt:pivotfilterbar?

    How to select Multiple items in the filters in the dvt:pivotfilterbar?

    To select multiple media and other files, it's not possible. You can do so in messages as directed.
    To select multiple files, connect to your PC and select them.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • How to upload price for a item in price list using DTW ?

    hi all,
    How to upload prices of all the items in price list using DTW ?
    What are templates used for it ?
    Item masters were already created.
    Jeyakanthan

    Hi
    Create two Excel templates 'Items.xls' and 'Items_Prices.xls'
    Since you have already imported items, just have the record key and item code alone in the 'Items.xls' . For example:
    RecordKey.......ItemCode
    1.......................I0001
    2.......................I0002
    In the Items_Prices template, Fill Pricelist Number fromOPLN and Price of the Item
    RecordKey....LineNum......Price
    1......................1..............350.00   (Means for Item I001, Pricelist 1 is updated with 350)
    1......................2..............300.00   (Means for Item I001, Pricelist 2 is updated with 300)
    2......................1..............550.00   (Means for Item I002, Pricelist 1 is updated with 550)
    2......................2..............600.00    (Means for Item I002, Pricelist 2 is updated with 600)
    In step 4 of DTW, Choose
    Check - Update Exisiting Object
    Uncheck - Import New Object
    This should update the pricelist alone for the items

  • HT1349 how to delete multiple items in itunes

    how to delete multiple items in itunes

    I inported my music files and see that I have multiple copies on my files so now I have multiple copies in iTunes.
    Some are multiples, some are duplicates, some are from different dates and some do not work and have the symbol for this.
    Thus, I must be picky about which ones I delete.
    Looks like I will have to continue deleting manually.

  • How to select multiple items in ListView?

    Is it possible to select multiple items (rows) in ListView? I'm able
    to select only one item at a time.
    I'm running Forte 30F2 on Windows NT 4.0.
    Thanks in advance,
    Ramarao
    Get Your Private, Free Email at http://www.hotmail.com

    Ramarao,
    I talked to Forte support about this recently and they had nothing but
    bad news.
    They said that you cannot select multiple rows in a listview, and that
    this is a
    feature that will be in the next release ( release 4 ).
    I then asked if it was possible for me to highlight a row manually ( and
    do the multiple
    select myself ), and they said that also wasn't possible. This is due
    to the fact that
    there are no displaynode properties that effect display attributes (
    like font or color ).
    They suggested that I try changing the smallicon to show rows that have
    been 'selected'.
    In other words, when you ctrl-click on any particular row, you could put
    an icon at the
    beginning of a row that shows that this row has been clicked on.
    I'm still working on this myself, so I will keep you posted.
    Jeff Pickett
    From: Ramarao P[SMTP:[email protected]]
    Reply To: Ramarao P
    Sent: Tuesday, March 24, 1998 6:22 PM
    To: [email protected]
    Subject: How to select multiple items in ListView?
    Is it possible to select multiple items (rows) in ListView? I'm able
    to select only one item at a time.
    I'm running Forte 30F2 on Windows NT 4.0.
    Thanks in advance,
    Ramarao
    Get Your Private, Free Email at http://www.hotmail.com

  • How do i select multiple items on a page using firefox on a mac?

    I am trying to to figure how to select multiple items (email addresses) using firefox on a mac. I use a web based manage my business. I am trying to send emails to multiple people.
    I have tried clicking on the first email and hold the command key while selecting the others. The selection just jumps.
    I tried holding the shift key and and it selects everything between the 1st and 2nd email address I want to use.
    I also tried the control key which just brings up a menu.
    Any help would be greatly appreciated.

    This may just be a limitation of the email site you are using. Is this a public site that I can test and try to reproduce the issue?

Maybe you are looking for