When I click first time run button for query script the column department in solution is empty but If I click the second time without reload the form the department is appear.
Normally this error appears if one of the keys are not set in Workflow Configuration.
User need to have admin access to the site to make the Key settings.
Follow below steps to resolve this issue and let me know whether it works for you or not.
1) Go to Foundation Site- Settings
2) Open the Workflow Admin site.
3) Click on the Configuration Options icon and search for the key 'UseLegacySearchAlgorithm'.
Note: If this key does not exist on the site then please add it. This key name is CASE SENSITIVE.
4) By default the scope is Global. Please select the scope as a list for which the issue is occurring and set its value to 'false'.For example in this scenario scope will be "testb" and value is "false".
After performing these steps ; redeploy the solution and rerun the solution.
Please give it 5-10 minutes for the changes to take place.