0

An event receiver on an InfoPath library works only when updating columns that are not created by propagating values from Infopath(). In code below "change" is a regular lib. column and "ApprovalStatus" is infopath based column. The event receiver is a sandbox solution.

Commented-out code is throwing an error:

//properties.AfterProperties["change"] = "test1";

        if ( properties.AfterProperties["change"].ToString()  == "test1")
        {
            properties.AfterProperties["Status Indicator"] = field_green.Url;

        }
        //else if (properties.BeforeProperties["ApprovalStatus"].ToString() == "Approval Pending")
        //{
        //    properties.AfterProperties["Status Indicator"] = field_red.Url;
        //}

        //item.Update();
  • The question is not very clear.Basically after-properties and before-properties doesn't work in all types of event handlers such as synchronous and asynchronous. so revisit their usage and see. Share the error message for additional help. – kesava May 13 '15 at 0:10
  • OK. SO to simplify: Can i check the AFTER values of infopath coloumn called ["Status Indicator"] . Values for this coloum in itemAdding are always null. – Nemanja May 13 '15 at 19:13
  • //string value = properties.AfterProperties["Status Indicator"].ToString(); --this code works for regular column and not for site column where values are for some reason NULL.... – Nemanja May 13 '15 at 19:17
  • This can only work in Item-Added event. After properties will return null in item adding event. I really doubt if there is any difference in behaviour w.r.to site columns – kesava May 13 '15 at 19:33
  • Ok then. How do you update item in "Updated" event, i keep geting an exeption about using properties. Please insert code.Thanks – Nemanja May 13 '15 at 21:28
0

after-properties and before-properties doesn't work in all types of SharePoint event handlers such as synchronous and asynchronous.

After properties should be used only when the event context is Item-updated event.

Below code can help in disabling the subsequent events

this.disableeventfiring();
 //your update code.. //
this.enableeventfiring();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.