4

Why does this not work within URL buttons:

/XYZ/e?{!$ObjectType.myObject__c.fields.myField__c}=what+Ever

I know XYZ can be replaced by {!$ObjectType.myObject__c} but why can I not go further?

Edit:

PageMessage after saving Button:

Error: Field myObject__c.fields.myField__c does not exist. Check spelling.

3 Answers 3

2

According to this post $ObjectType is not evaluted within a custom button context. That was in April 2013 and doesn't say where the information came from, but it seems like not much has changed since then.

As for why exactly, that might be a question worth raising with Salesforce support

2
  • but as mentioned {!$ObjectType.myObject__c} somehow works fine in button context
    – itsmebasti
    Commented Jun 12, 2015 at 15:45
  • 1
    Yes, I did think of that while leaving my comment. Best guess is that it can only resolve information at the object level but can't go any deeper than that, but that's just a guess. MKT's answer gives a decent workaround to the problem, but that still leaves the original question as to why you can't go further unanswered. Commented Jun 15, 2015 at 12:56
0

Does your code reside in a namespaced environment, or reference objects/fields from a managed package? Because if so, you'll need to explicitly include the appropriate namespacing in your $ObjectType reference since button context is much less "self-aware" than other parts of the platform.

0

It seems you are trying to pass some value through URL while creating new record. This can be done in following way.

Each field (custom or standard) in Salesforce has its unique ID, and you can use the same to prep-populate the fields on record create page.

To get Custom Field ID

  1. Go to list of fields, and click on any custom field.
  2. In URL, you will find the Custom Field ID

    Custom Field ID

To get Standard Field ID

  1. Standard fields have predefined IDs.
  2. Check in HTML of Record edit page, and you'll find the one.

    Standard Field ID

Once you get required Field IDs, you can use generic record create URL with parameters. For e.g. Say I need to create a Lead Record, and I want to pre-populate Company and another custom field. ID of custom field is 00N90000003YET3 and ID of Company is lea3, so your URL should look like: https://ap1.salesforce.com/00Q/e?00N90000003YET3=Test&lea3=Test

Hope this helps, please write back if you are looking for anything else.

You must log in to answer this question.

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