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

1 Answer 1

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.

2
  • 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
    Commented Jun 17, 2015 at 19:07
  • I saw your blog and good work buddy. You could also have shared few screenshots for demonstration. Commented Jun 17, 2015 at 20:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .