views:

197

answers:

2

Hi, i have written the following event handler code to update a column in the document library, on checkin of a document:

Select Case listEvent.Type

Case SPListEventType.CheckIn

  sLog = sLog + "Newest Item is Checked-out" + vbCrLf
  Dim ApproveStatusBoolean As Boolean = True

  For Each oField In oItem.Fields
    If (oItem("ApproveStatus") = "Rejected") Then
      ApproveStatusBoolean = False ' Old document for re-review
      Exit For
    End If
  Next

  If (ApproveStatusBoolean = False) Then
    oItem("ApproveStatus") = "Submitted"
    oItem.Update()

    SmtpMail.Send(objMailMesg)
  End If
End Select

I find that the ApproverStatus column is getting updated if i checkin the document from the document library but it is not happening if i checkin the document from inside the word document when it promts for "other users cannot see your changes untill you checkin. do u want to checkin?".

can you please help me to know what is going wrong how to get the column updated if i checkin from inside also.

or is there any way by which i can turn off that prompt itself.

+1  A: 

The first thing you should do is to varify that the same event is fired in both cases. I would do that by writing some debug statements to a log file, but I am also kind of ol' school. If I was to debug that code I would outcomment most of the code like the SMTP mail statement in order to raise the signal to noise ratio.

Once that is handled you can dig into the root cause

Kasper
Yes, what event are you using? http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventreceiver_members.aspx
s_hewitt
The problem is "SmtpMail.Send(objMailMesg)" call is working in both cases. So we can kind of assume that the calls " oItem("ApproveStatus") = "Submitted" oItem.Update()"Are getting called. So we can kind of rule out the logical error case.
minu
A: 

There may also be an issue with your code. Try the following...

Select Case listEvent.Type

Case SPListEventType.CheckIn

  sLog = sLog + "Newest Item is Checked-out" + vbCrLf

  If (oItem("ApproveStatus") != "Rejected") Then
    oItem("ApproveStatus") = "Submitted"
    oItem.Update()
    sLog = sLog + "Item has set to ApproveStatus:Submitted" + vbCrLf
    SmtpMail.Send(objMailMesg)
  End If

End Select

You are also going to have different results if you use a non-office document or an office 2003 document. You will have to test these as well. Be aware that using a synchronous event with Office 2007 documents may lead to the event being called, but subsequently being overwritten by the old value stored within the office document itself.

Nat