Recently we had an instance where a Gravity Form containing some custom JS became corrupted, with half of the code missing. I was able to restore the original Javascript from a SQL backup doing the following:
- Download a SQL backup (in my case I use Updraft) with a known “good” Gravity form
- Open the extracted backup (I’m using VS code)
- Search for your form’s title, in my case it’s “Ram Food Recovery Event Registration”
- Then I found something that looks like this:
(17, ‘{“title”:”Ram Food Recovery Event Registration”,”description”: … ,”enableAttachments”:false}}’), - Luckily for us Gravity Forms saves custom code in plaintext, but we’ll have to finesse it a bit.
- First remove the newlines and tabs ( \\n and \\t)
- Next replace \\” with “
- Next replace \\/ with /
- Finally you should have some functional Javascript code. In my case I also pasted the code within an online JS beautifier tool to properly ident/format it for easier reading