Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 19, 2018 @ 10:01
    Simon Dingley
    0

    Programatically Updated DataType Prevalue Sort Order

    After a long battle trying to programmatically create prevalues for a datatype I have had some success (not sure why it's quite so difficult?) but I now can't seem to update the sort order for existing prevalues. Anyone got any ideas how to achieve it given that the sort order field is read-only? I'm trying to keep the options in alphabetical order.

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Jan 19, 2018 @ 12:12
    Kevin Jump
    1

    Hi

    As you say SortOrder is readonly, so i think the only way to do it. is to remove the existing preValue from the datatype prevalue collection and then add it back in with the SortOrder passed in the constructor.

    itemPreValues.Add(alias, new PreValue(id, value, sortOrder));
    

    if you are doing a insert and want to update all the sort orders - its probably easier to just create a new PreValue dictionary collection, and go through the existing ones putting all new PreValues into the new collection and set that back to the datatype once you're done.

    _dataTypeService.SavePreValues(item, mySortedPreValues);
    
  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 19, 2018 @ 16:00
    Simon Dingley
    0

    Thanks Kevin, I'll give that a go then.

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 22, 2018 @ 11:40
    Simon Dingley
    0

    Kevin, in making changes like this programmatically it will presumably mean the Lucene index is incorrect as I noticed it stores the prevalue id rather than the value. So, if I remove and add them again the document(s) using the datatype would need to be republished with the new prevalue id's? Is that correct?

Please Sign in or register to post replies

Write your reply to:

Draft