Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Dupont 61 posts 115 karma points
    Aug 08, 2013 @ 10:43
    David Dupont
    0

    PropertyType.Save doesn't seems to work anymore

    Hello, I'm currently trying to use the following code to update a DocumentType properties programmatically. I get the property from the correct ContentType by alias then I update properties and call Save(). but it seems that updated value //get property var property = contentType.getPropertyType(propertyAlias); // updating property.Name = propertyName; property.Mandatory = propAttr.Mandatory; property.ValidationRegExp = propAttr.ValidationRegExp; property.Description = propAttr.Description; property.SortOrder = propertySortOrder; property.Save(); But it seem that update is not made since when I look at the backend or in the database for this property calue is still the same. I test the backend to be sur that everything is fine and property updates is OK from there. Thanks per advance for your time. David

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Aug 08, 2013 @ 12:15
    Jeroen Breuer
    0

    Hello,

    Where in the code do you try to update a documenttype? Some events have changed so some things won't work anymore in the beforesave or aftersave event.

    Jeroen

  • David Dupont 61 posts 115 karma points
    Aug 08, 2013 @ 15:24
    David Dupont
    0

    Crap formatting didn't work here is my code :-) :

    //get contentType
    var docType = DocumentType.GetByAlias(docTypeAlias);
    var contentType = docType as ContentType;
    
    //get property
    var property = contentType.getPropertyType(propertyAlias);
    
    //properties filling
    property.Name = propertyName;
    property.Mandatory = propAttr.Mandatory;
    property.ValidationRegExp = propAttr.ValidationRegExp;
    property.Description = propAttr.Description;
    property.SortOrder = propertySortOrder;
    
    property.Save();
    
    docType.Save();
    

    I didn't save anything regarding documentType I only try to change sortOrder and some other property value.

    Should I do something with the contentType reference I get.

    I don't use the new ContentTypeService to do my change but the legacy API.

    Hope this helps

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft