1

私は SharePoint を初めて使用し、この作業に数日間取り組んできました。何とか ItemAdded イベント レシーバーを使用できましたが、リスト 1 を更新する場合は、ItemUpdated イベント レシーバーを使用してリスト 2 も更新する必要があります。コーディング部分に苦労しています。あるリスト内の項目を別のリストにリンクする方法と、更新する方法。

4

1 に答える 1

2

「ItemAdded」イベントの例を次に示します。itemupdatingイベントはこれと同様に機能します。この例では、新しいアイテムが「タスク」リストに追加されるたびに、イベントレシーバーは同様のアイテムを「スキルと能力」リストに追加します。

        // ITEM ADDED
        public override void ItemAdded(SPItemEventProperties properties)
        {
            base.ItemAdded(properties);

            try
            {
                String curListName = properties.ListTitle;
                if (_applicableLists.Contains(curListName))
                {

                    if (properties.ListItem.ContentType.Name == "Discussion")
                    {

                        if (curListName == "Tasks")
                        {
                            SPList saList = properties.Web.Lists["Skills & Abilities"];
                            SPListItem saItem = SPUtility.CreateNewDiscussion(saList, properties.ListItem["Task Text"].ToString());
                            SPFieldLookupValue taskLookup = new SPFieldLookupValue();
                            taskLookup = new SPFieldLookupValue(properties.ListItem.ID, (string)properties.AfterProperties["Task ID"]);
                            saItem["Task Lookup"] = taskLookup;
                            saItem["Title"] = properties.ListItem["Task Text"].ToString();
                            saItem["Body"] = "Please leave a comment by clicking the Reply link on the right of this message.";
                            saItem[_inStatus] = "New";
                            // perform the update with event firing disabled
                            EventFiringEnabled = false;
                            saItem.Update();
                            EventFiringEnabled = true;

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // handle exception...
            }
        }

また、SharePointに焦点を当てるために、sharepoint.stackexchange.comサイトを確認することをお勧めします。幸運を!

于 2013-02-21T14:08:55.610 に答える