Editing value of widget parameter within notebook code

DavidOBrien
New Contributor

I have a notebook with a text widget where I want to be able to edit the value of the widget within the notebook and then reference it in SQL code. For example, assuming there is a text widget named Var1 that has input value "Hello", I would want to be able to do the following:

 

originalValue = dbutils.widgets.get('Var1')

dbutils.widgets.text('Var1', originalValue + ", World!")

%sql

select '${Var1}' -> returns 'Hello, World!'

 

However, whenever I try an approach like this in my notebooks, it does not update the value in Var1 and will select the original 'Hello' value. How can I fix this? Thank you