Skip to content

Custom Field Choices in custom script ObjectVar #18088

Closed Answered by Zombie-Toad
Zombie-Toad asked this question in Help Wanted!
Discussion options

You must be logged in to vote

After a lot of trial an error I came up with this solution:

from extras.models.customfields import CustomFieldChoiceSet
from extras.scripts import ChoiceVar, StringVar, ObjectVar, IPAddressWithMaskVar, Script

class NewPrinterScript(Script):
    class Meta:
        name = "New printer"
        description = "Creates a new printer"
        field_order = ['name','ip_address','win10driver']
      
    win10drivers_list = CustomField.objects.get(id=2).choices
    name = StringVar(
        description = "Printer Name"
    )
    ip_address = IPAddressWithMaskVar(
        description = "IP address of the printer"
    )
    win10driver = ChoiceVar(
        description = "Windows 10 driver",
        

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Zombie-Toad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant