I have a field named ‘territory’ which has 4 options (display=value):
USA = 1
Canada = 2
Mexico = 3
Other International = 4
Then, later on the form I have a field named ‘country’, which I can hide for 1-3 and I show if 4 is chosen in territory. I want to be able to automatically fill in the country based on what is selected in territory.
Sorry, forgot this part. For that to be useful, you will need to first enable logging:
With the modified code, and with logging enabled, please test the form. Then go back to the Forms > Settings > Logging page, and view the Gravity Forms Core log. Share the link to the log file if you need help figuring out what is going on.
This helped and I can see that my field is getting switched out, but I probably should have been clearer about the true goal. My issue is actually that I need these values to be updated for a webhook that I’m trying to process. Based on the log timestamps it looks as though the input_14 is updated to United States before the webhook happens, but even though I’ve mapped that field (country) in the pre_submission it’s not getting handed off to the webhooks.
From the GForm log (note the timestamps):
2020-05-28 21:47:34.169352 - DEBUG --> pre_submission_handler(): Matched United States.
2020-05-28 21:47:34.169373 - DEBUG --> pre_submission_handler(): The modified POST => Array
(
[input_1] => 1
[input_2] => caleb@email.com
[input_4] => CA
[input_5] => FM
[input_6] => (123) 456-7890
[input_7_1] => 123
[input_7_2] => 23
[input_7_3] => SGF
[input_7_4] =>
[input_7_6] => United States
[input_10_1] => Missouri
[input_10_2] => Greene
[is_submit_2] => 1
[gform_submit] => 2
[gform_unique_id] =>
[state_2] => WyJbXSIsIjI0YjVkNTRmYWYwNzZjMDQ5NzI4YmU1YzRhNmI4NTU0Il0=
[gform_target_page_number_2] => 0
[gform_source_page_number_2] => 1
[gform_field_values] =>
[input_14] => United States
)
From the webhooks log: 2020-05-28 21:47:35.609162 - DEBUG --> GF_Webhooks::process_feed(): Sending webhook request to [url-ommitted]?territory=1&country&emailAddress=caleb%40email.com&name=CA&company=FM&phone=%28123%29+456-7890&streetAddress1=123&streetAddress2=23&city=SGF&state=Missouri&county=Greene&ipAddress=75.98.104.178; Array
Any thoughts on how to get that to the webhook before it’s sent?
There are a few fields that aren’t required, but I’d to send them as blank as well, so a similar function will solve that for me as well.