Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have an listadded eventreceiver with the following code:

 public override void ListAdded(SPListEventProperties properties)
 {
    SPWeb web = properties.Web;
    bool safeUpdates = web.AllowUnsafeUpdates;
    web.AllowUnsafeUpdates = true;
    SPList list = properties.List;

    SPField VanField  = list.Fields.GetFieldByInternalName("MyFieldName");
    VanField.ShowInEditForm = false;
    VanField.ShowInNewForm = false;
    VanField.Update(true);
    list.Update(true);
    web.Update();

    web.AllowUnsafeUpdates = safeUpdates;
    base.ListAdded(properties);
}

The problem i have is that the ShowInEditForm and ShowInNewForm not saved to the fields.

The event is an sychronous event. THe field is an Taxonomy field, maybe that's the problem.

share|improve this question
Are you sure that your EventReceiver is called after the list creation? Did you try to put a breakpoint in the method and debug it? – Norbert Dec 12 '12 at 11:18
Yes i'm sure. It's running the code – Active_t Dec 12 '12 at 11:23
I would try making this Added event synchronous. This way it will run 100% AFTER the list has been committed to the database. – Norbert Dec 12 '12 at 11:35
It's already synchronous – Active_t Dec 12 '12 at 11:42

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.