URL Hack: Pass additional parameters into the saveURL

  • I'm pretty good with URL hacks to set field values in a record, save=1, saveURL/retURL, etc... But I'm getting stuck on something I've never tried before and I don't even know if it is possible. Is it possible to add parameters into the saveURL string?

    e.g. /id/e?field1=blah&save=1&saveURL=aDifferent.Id/e?field2=blah&field3=yada

    So in other words, what I'm interested in doing is, Update a field on one record with an auto-save, then return to a related ID of a different record on the edit page (all good up to this point). However, I can only seem to pass a single field update after the ? and anything after the ?field2=blah gets dropped and the edit screen won't show the &field3=yada update.

    Ultimately, I'd also like to add in an &save=1 on the saveURL string also, so one button can modify and save one record, then modify and save another record. I'm trying to accomplish this without code if I can. Any ideas?

    how are you building this url are you doing this from a button/ visualforce page? have you looked into URLFOR Function?urlfor('/001',''["id"="001abc","field1"="abc"]) http://salesforcesource.blogspot.com/2008/12/urlfor-function-finally-explained.html

    This is a Custom button... I saw URLFOR and tried to understand it in the Help files, but I don't quite understand it. Any advice on how to plug it into the example above to update multiple field values in the saveURL?

    Did you face any issues like & in the values your passing through the URL hack and if yes how did you overcome them. Can someone help me as i am having a Script on custom button when clicked passing valued to a object. However, few of the picklist values have & in them eg: India & China its not working. Tried encodeURIComponent too, still facing issues. Any help would be appreciated.

  • eyescream

    eyescream Correct answer

    8 years ago

    Easy :)

    Just urlencode your params again. That way they'll get decoded when SF is examining your saveURL. For example:

    1. URL to make new Task: /00T/e?tsk5=Hi%20SF%20Stack!&tsk6=Look%20Ma,%20no%20hands!
    2. Go to http://meyerweb.com/eric/tools/dencoder/ or any other tool of your choice (URLENCODE function, javascript's encodeURIComponent... pick your poison).
    3. You should end up with something like %2F00T%2Fe%3Ftsk5%3DHi%2520SF%2520Stack!%26tsk6%3DLook%2520Ma%2C%2520no%2520hands!
    4. That's your saveURL.

    The only problem is that this seems to somehow skip the code that generated "Recent Items" in the sidebar. So after I've saved an Account and I eventually end up on this new Task page, I don't see it in the sidebar. Only when I'll navigate to any other page it pops up.

    enter image description here

    does this apporach auto save @eyescream? after autopopulating the fields?

    The derp is strong with this one...

    @rao yes, just slap encoded `save=1` at the end. Full URL to "show me new Acc page and on save make new Task" would be `/001/e?saveURL=%2F00T%2Fe%3Ftsk5%3DAutosave%26tsk6%3DLook%2520Ma%2C%2520no%2520hands!%26save%3D1`.

    @user320 You've started a fashion, you reap what you sow :)

    This looks great! Thank you for the idea! I'll try it out when I have some time in the next couple days!

    @JasonPaquette you're welcome but to be honest I'm not sure what you all are trying to achieve. I sense some homemade workaround for homemade "rollup summary" or maybe "on child case edit reopen parent Case" and while that's tempting to achieve like that, it'll fail as soon as some kind of API integration kicks in. That's what triggers are for.... What's your use case?

    This worked well except to make sure you don't encode the tokens (e.g. don't encode the {!fieldname}) but as long as I encode the &, =, ?, /, etc this worked great! This is a user-initiated process only, so I'm not sure how any API integration would break it? I just want to update/save two records via one button click instead of two button clicks. We have a custom object with a relationship to Leads and I want to update fields on the custom record and the parent Lead record.

    As long as you're aware of the fact that it won't fire automatically when you'll mass update these custom records from Data Loader for example - you'll be fine. I'm also a bit surprised you had to skip encoding of field names :) Do you have an example? They should be alphanumeric only so safe, looking same after encoding...

    NOTE: The URL format Salesforce uses for the standard UI is not a supported API and thus subject to change. futher reading this

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM

Tags used