문제

SharePoint 2007을 사용하여 문서 라이브러리의 항목 업데이트 이벤트의 필드를 설정하는 데 문제가 있습니다.

나는 다음과 같은 상황을 가지고 있으며, 문서 라이브러리가 있고, 하나의 lookupfield를 기반으로 문서를 추가 할 때 Pakerer가있는 다른 조회 필드에 값을 추가하려고하지만 실패합니다.

그러나 문서 라이브러리에 이미 문서가 있고 속성 편집에 문서가있는 경우 항목을 수정하고 업데이트하면 필드를 업데이트합니다.

나는 이것에 불일치를 유의하고, 즉 내가 업데이트 할 때 나는이 종류의 데이터를 현장으로 통과시킬 때, 58; #somevalue; # 59; # somevalue2; # 60; # somevalue3 ...

그러나 템플릿에 문서를 추가 할 때 조회 필드를 채 웁니다. Picker가있는 다른 조회 필드로 전달하기 위해 다음과 같은 것들을 얻습니다. 58; 58; # 60; #

그래서 ID의 ID가 전달되었음을 의미하지만 값은 비어 있지만 값을 작동시키기 위해 값을 가질 필요가있는 것 같습니다.

i h 다음 코드 :

public override void ItemUpdating(SPItemEventProperties properties)
        {
            base.DisableEventFiring();
            base.ItemUpdating(properties);

            string nameLookUp = "LookUpField";
            string namePickUp = "LookUpFieldWithPicker";


            string opp = properties.BeforeProperties[namePickUp]==null ? string.Empty : properties.BeforeProperties[namePickUp].ToString();
            string npp = properties.AfterProperties[namePickUp] == null ? string.Empty : properties.AfterProperties[namePickUp].ToString();

            string op = properties.BeforeProperties[nameLookUp] == null ? string.Empty : properties.BeforeProperties[nameLookUp].ToString();
            string np = properties.AfterProperties[nameLookUp] == null ? string.Empty : properties.AfterProperties[nameLookUp].ToString();

            if (!string.IsNullOrEmpty(npp) && opp != npp)
            {
                SPFieldLookupValueCollection value = new SPFieldLookupValueCollection(properties.AfterProperties[namePickUp].ToString());
                properties.AfterProperties[nameLookUp] = properties.AfterProperties[namePickUp];
            }
            else if (!string.IsNullOrEmpty(np) && op != np)
            {
                 properties.AfterProperties[namePickUp] = properties.AfterProperties[nameLookUp];
            }

            base.EnableEventFiring();
        }
.

누구든지 나에게 조언 할 수 있기를 바랍니다 ... 감사합니다

도움이 되었습니까?

해결책

Take reference to lookup list and use List.GetItemById(Id) to get the item and take the column value and construct the lookup collection. Example: SPList lookupList=properties.web.lists["lookupListName"]; SPListItem lookuplistitem=lookupList.GetItemById(4); //Here Id is 4 string filedvalue=lookuplistitem["lookupfieldname"];//Which field you are taking as lookup now construct the fieldlookup and do the same for all id's and construct fieldlookupvaluecollection.

List.GetItemById(Id) query is faster so you will not get much performance issues.

다른 팁

As per my understanding there are two lookups from same list/library. SPFieldLookupValueCollection for each field is different. The format is ID;#Value here ID is listitem ID and Value is what you stored for respective fields in lookup list.

For "LookUpField" "ID;#LookUpFieldValue"

For "LookUpFieldWithPicker" "ID;#LookUpFieldWithPickerValue"

Before updating the listitem you have to construct the lookup collection like this

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top