Copied to clipboard

Flag this post as spam?

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


  • Biagio Paruolo 1494 posts 1635 karma points c-trib
    Sep 06, 2017 @ 12:25
    Biagio Paruolo
    0

    Dropdown List: assign value. Is there a new method?

    Hi,

    I'm using this code to assign value to dropdown datatype. is there a new mode to do this? Thx

    // I need to find the Id of the 'Reserved' prevalue option on the Status data type I created
                    var dts = ApplicationContext.Current.Services.DataTypeService;
                    // Get an instance of the status editor
                    var statusEditor = dts.GetAllDataTypeDefinitions().First(x => x.Name == "Vendor Request State");
    
                    //// Now we can fetch the pre-values collection, and use linq to find the Id for the 'Reserved' option
                    int preValueId = dts.GetPreValuesCollectionByDataTypeId(statusEditor.Id).PreValuesAsDictionary.Where(d => d.Value.Value == data.StatoRichiesta).Select(f => f.Value.Id).First();
    
                    var prevalues = dts.GetPreValuesCollectionByDataTypeId(statusEditor.Id);
    
    
    
                    foreach (var prevalue in prevalues.PreValuesAsDictionary)
                    {
                        LogHelper.Info<WFPraticheController>(prevalue.Value.Id.ToString());
                        LogHelper.Info<WFPraticheController>(prevalue.Value.Value);
                    }
    
                    post.SetValue(Vendor.GetModelPropertyType(x => x.StatoRichiesta).PropertyTypeAlias, preValueId);
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies