Ok, I need to pre populate a drop down before I show it in a WorkflowType.
Using the code below;
[Umbraco.Forms.Core.Attributes.Setting("Method", description = "Testing", prevalues = "List 1,List 2,List 3", control = "Umbraco.Forms.Core.FieldSetting.Dropdownlist")]
public string MadMimiMailingList { get; set; }
Gives me;
Which is sort of what I want, but I want to show my own data dynamically. I know I can just change this value and it'd show me whatever I like - but the values I want to use are not constant or static.
prevalues = "List 1,List 2,List 3"
I can change this value and the dropdown changes, but I don't know how to set it dynamically - ideally I'd call a method that would give me a list of prevalues
I have studied the infamous Country Dropdown, but that's for use within the forms, not on the actual workflow...
Thank you! The only bit I had to change was the settings["MadMimiMailingList"] to be the name of my property.
The final, working code...
[Setting("Mailing List", description = "Please select the MadMimi mailing list", prevalues = "List 1,List 2,List 3", control = "Umbraco.Forms.Core.FieldSetting.Dropdownlist")]
public string MadMimiMailingList { get; set; }
public override Dictionary<string, Setting> Settings()
{
var settings = base.Settings();
// open new api
var madMimiApi = new MadMimiApi();
// try and get all the lists
var allAvailableLists = madMimiApi.GetAllLists();
var preValues = String.Join(",", (allAvailableLists.Select(list => list.Name).ToArray()));
// add to prevalues
settings["MadMimiMailingList"].prevalues = preValues;
// done
return settings;
}
Prepopulate dropdown list for use in workflow
Ok, I need to pre populate a drop down before I show it in a
WorkflowType
.Using the code below;
Gives me;
Which is sort of what I want, but I want to show my own data dynamically. I know I can just change this value and it'd show me whatever I like - but the values I want to use are not constant or static.
I can change this value and the dropdown changes, but I don't know how to set it dynamically - ideally I'd call a method that would give me a list of
prevalues
I have studied the infamous Country Dropdown, but that's for use within the forms, not on the actual workflow...
Is it possible to use the Settings method override? Compile the settings in there and you should be able to dynamically build the PreValues.
EDIT: You've probably worked it out by now but:
Cheers
Thank you! The only bit I had to change was the
settings["MadMimiMailingList"]
to be the name of my property.The final, working code...
Wow that is awesome did not know you could do that!!!
Comment author was deleted
Yeah same here :) awesome
Comment author was deleted
You could also create a custom field setting type, but guess this is easier
Still concerning this, is it possible to get the name of the current form that has this workflow in this method?
is working on a reply...