3

I'm trying to pre-populate fields on a custom object that I made. I tried passing the values through the url using a button link, overriding the default new button and providing the ids of the fields on that page, which works in my original org. However when migrating the changes to another org, the ids don't sync up, causing the fields not to populate.

Is there an easy way to pass arguments through the url more generically, other than hard coding values to page element ids?

2

You cannot query Field Id because that is not accessible in SOQL. Hence, there is no generic solution to avoid the hardcoding.

However, you can utilize Tooling API in Salesforce to query CustomObject Id and CustomField Id. But I am not sure if we can use Tooling API inside a Custom button. See this and work it out. Let us know if you find a feasible solution using the link.

| improve this answer | |
  • I was looking for something less invasive, but I did try out the solution on this page. threeheadsonapike.wordpress.com/2013/02/11/…. Just added the files into my dev org and it worked right away. I have yet to look into your link too extensively. – Andrew Jun 17 '15 at 19:07
  • I saw your blog and good work buddy. You could also have shared few screenshots for demonstration. – the_phantom Jun 17 '15 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.