Unable to set value for dynamic text box

Hi, I am not able to make dynamic text box working on our hammer-4:roll_eyes:
I have no problems with setting content of dynamic dropdown, but text box is never working…
I tried everything what I found here and in docs:

From simple:

username=“TEST”
$evm.object[‘value’] = username

To complex:

username=“TEST”
$evm.object[‘default_value’] = username
$evm.object[‘values’] = username
$evm.object[‘value’] = username
$evm.object[‘visible’] = true
$evm.object[‘display’] = :edit
$evm.object[‘required’] = false
$evm.object[‘data_type’] = :string

But nothing was working. My text box settings:



image

This is HTTP 200 response after refresh button click:

{
“success”: true,
“message”: “Refreshing dialog fields for Service Dialog id:26 label:‘DIALOG TEST’”,
“result”: {
“text_box_1”: {
“name”: “text_box_1”,
“description”: “”,
“data_type”: “string”,
“notes”: null,
“notes_display”: null,
“display”: “edit”,
“display_method”: null,
“display_method_options”: {},
“required”: false,
“required_method”: null,
“required_method_options”: {},
“default_value”: “”,
“values_method”: null,
“values_method_options”: {},
“options”: {
“protected”: false
},
“label”: “Text Box”,
“position”: 3,
“validator_type”: “f”,
“validator_rule”: null,
“reconfigurable”: false,
“dynamic”: true,
“show_refresh_button”: true,
“load_values_on_init”: true,
“read_only”: false,
“auto_refresh”: false,
“trigger_auto_refresh”: false,
“visible”: true,
“type”: “DialogFieldTextBox”,
“resource_action”: {
“action”: null,
“resource_type”: “DialogField”,
“ae_namespace”: “DialogHelpers/Test”,
“ae_class”: “Test”,
“ae_instance”: “Test”,
“ae_message”: null,
“ae_attributes”: {}
},
“dialog_field_responders”: ,
“values”: “TEST”
}
},
“href”: “https://XXXXXXX/api/service_dialogs/26
}

Any hints?
Thank you…

2 Likes

Having the same problem setting a value to a dynamic text box for vm_name. It’s like the value doesn’t stick after it leaves the form. I’m new to this, but feel like it should work.

I’m deriving my naming convention from the other fields to a string and assigning the string in the vm_name dynamic text box. I can see the value being set in my custom method for the dynamic field and can see the value when running object walker and in the UI text box BUT when the provisioning runs the value is not there. Is this a bug? Is it that I’m not putting my method in the right class to allow access to the variables? I don’t know, but I wish I could get it working.

@johny5v I can’t see anything obvious wrong in the screenshots. Can you confirm that the method is running (e.g. by adding a log line)? Every time I had a dynamic method not working, it turned out to be a typo :slight_smile:

@silverwulf Do you see the value if you run object_walker in the StateMachine? How do you access the value in your StateMachine?
Are you running from a Service Catalog Item?

Hey buc,
Thanks for taking a look.

Yes its a Service Catalog item to provision a Vmware VM. I do see the value when I run object_walker in my method and it updates the dynamic field with the correct value. However when the provisioning of the vm begins the value of the vm_name field disappears when it begins the provisioning.

Im thinking that I may need to somehow get into the miqprovisioning object and assign the value directly there instead of the dialog.

– screenshots of the field and the form
field

— Heres my method call for the dynamic variable where I concatenate my strings:

Pillar = $evm.root[‘dialog_var_BCM_Pillar’]
Platform = $evm.root[‘dialog_var_Platform’]
System = $evm.root[‘dialog_var_System’]
AppCode = $evm.root[‘dialog_var_AppCode’]
ServerRole = $evm.root[‘dialog_var_ServerRole’]
Environment = $evm.root[‘dialog_var_Environment’]
Svr_Number = $evm.root[‘dialog_var_Svr_Number’]
Dynamic_Hostname = $evm.root[‘dialog_dynamic_vm_name’]
Whole_Hostname = $evm.root[‘dialog_vm_name’]
TargetVMName = $evm.root[‘dialog_option_1_vm_target_name’]
$evm.log(:info, “#################################################”)
$evm.log(:info, “Before the processing”)
$evm.log(:info, “#################################################”)
$evm.log(:info, “The value of the Dialog before the assignment is: #{Whole_Hostname}”)
$evm.log(:info, “The current evm.object value before the assignment is: #{$evm.object[‘value’]}”)
$evm.log(:info, “String is #{Pillar}#{Platform}#{System}-#{AppCode}#{ServerRole}-#{Environment}#{Svr_Number}”)
#var_concatenated_string = " "
var_concatenated_string = “#{Pillar}#{Platform}#{System}-#{AppCode}#{ServerRole}-#{Environment}#{Svr_Number}”
list_values = {
‘required’ => false,
‘protected’ => false,
‘read_only’ => false,
‘data_type’ => “string”,
‘value’ => var_concatenated_string,
}
$evm.log(:info, “#################################################”)
$evm.log(:info, “Iterate through evm.object variable”)
$evm.log(:info, “#################################################”)
list_values.each do |key, value|
$evm.log(:info, “Setting dialog variable #{key} to #{value}”)
$evm.object[key] = value
end
$evm.log(:info, “#################################################”)
$evm.log(:info, “Results after assignment”)
$evm.log(:info, “#################################################”)
$evm.log(:info, “The value of the evm object is now #{$evm.object[‘value’]}”)
$evm.log(:info, “The direct evm.root vm_name is now #{$evm.root[‘dialog_vm_name’]}”)
$evm.log(:info, “The direct vm_name value field of the variable vm_name is now #{$evm.root[‘dialog_vm_name’]}”)
$evm.log(:info, “The direct vm_name value field of the variable dialog_option_1_vm_target_name is now #{$evm.root[‘dialog_option_1_vm_target_name’]}”)

After the provisioning starts the dialog_vm_name is blank. Its like it doesnt save it to the permanent variable or something.

@buc The method is running, you can even see the value “TEST” in HTTP response when field is refreshing…

@silverwulf I observe myself strange behaviour when clicking on request detail - all dynamics methods are being invoked again at that moment (and some aren’t resolved, because they use evm object / data which is not available or different at the moment). I don’t understand why request detail doesn’t simply show dialog values which were there during user submit. Sometimes it also takes quite much time where you have many dynamics fields there :frowning: But that has no impact on the provisioning itself, values there are correct (in my case)