# Convert string dropdown to Integer for use in SP

**URL:** <https://forum.inductiveautomation.com/t/convert-string-dropdown-to-integer-for-use-in-sp/8047>\
**Category:** Ignition\
**Created:** [February 24, 2014, 4:30pm UTC](https://forum.inductiveautomation.com/t/convert-string-dropdown-to-integer-for-use-in-sp/8047 "2014-02-24T16:30:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbackus](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tbackus/32/5091_2.png) [@tbackus](https://forum.inductiveautomation.com/u/tbackus)\
**Post date:** [February 24, 2014, 4:30pm UTC](https://forum.inductiveautomation.com/t/convert-string-dropdown-to-integer-for-use-in-sp/8047/1 "2014-02-24T16:30:26Z")

</div>

Ok I have a form  
2 dropdowns and a submit button

1st dropdown string  
Machine1  
Machine2  
Machine3  
Machine4

2nd Dropdown - retrieved from stored procedure  
exec spGetMachineSchedule @MachineID = “{Root Container.MachineID.selectedLabel}”, @Option = ‘workorder’

Basically this dropdown fills in with scheduled workorders based on the selection of the 1st dropdown. data is received as Integer

Submit button:  
MachID = event.source.parent.getComponent(‘MachineID’).selectedLabel  
WOID = event.source.parent.getComponent(‘WorkOrder’).selectedLabel

call = system.db.createSProcCall(“spSetMachineWorkOrder”,“mdvsites”)  
call.registerReturnParam(system.db.INTEGER)  
call.registerInParam(1, system.db.VARCHAR, ‘MachID’)  
call.registerInParam(2, system.db.INTEGER, ‘WOID’)  
system.db.execSProcCall(call)

#Print the result to the console  
print call.getReturnValue()

Result:  
caused by Exception: Error executing system.db.execSProcCall()  
caused by GatewayException: Error trying to coerce ‘WOID’ [String] to a class java.lang.Integer

Not sure what to do from here… I assume I would need to use “toInt” just not sure where…

Thanks for pointing me in the right direction.

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [February 24, 2014, 6:10pm UTC](https://forum.inductiveautomation.com/t/convert-string-dropdown-to-integer-for-use-in-sp/8047/2 "2014-02-24T18:10:00Z")

</div>

First try removing the quotes from your variable names:

```auto
MachID = event.source.parent.getComponent('MachineID').selectedLabel
WOID = event.source.parent.getComponent('WorkOrder').selectedLabel

call = system.db.createSProcCall("spSetMachineWorkOrder","mdvsites")
call.registerReturnParam(system.db.INTEGER)
call.registerInParam(1, system.db.VARCHAR, MachID) #<--------------- HERE
call.registerInParam(2, system.db.INTEGER, WOID) #<--------------- AND HERE
system.db.execSProcCall(call)

#Print the result to the console
print call.getReturnValue()
```

If you need, use [int](http://docs.python.org/2/library/functions.html#int) in Python:

```auto
MachID = event.source.parent.getComponent('MachineID').selectedLabel
WOID = event.source.parent.getComponent('WorkOrder').selectedLabel

call = system.db.createSProcCall("spSetMachineWorkOrder","mdvsites")
call.registerReturnParam(system.db.INTEGER)
call.registerInParam(1, system.db.VARCHAR, MachID)  
call.registerInParam(2, system.db.INTEGER, int(WOID)) #<--------------- USE INT HERE
system.db.execSProcCall(call)

#Print the result to the console
print call.getReturnValue()
```

---

<div class="post-metadata">

**Author:** ![tbackus](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tbackus/32/5091_2.png) [@tbackus](https://forum.inductiveautomation.com/u/tbackus)\
**Post date:** [February 24, 2014, 7:34pm UTC](https://forum.inductiveautomation.com/t/convert-string-dropdown-to-integer-for-use-in-sp/8047/3 "2014-02-24T19:34:58Z")

</div>

DOH!!!

Thanks adamaustin. removing quotes took care of it…
