1

I have created visualforce page to include command button which allows to create a new contact.

My VF page code:

<apex:page standardController="Contact"  >
    <apex:form>
        <apex:pageBlock>
            <apex:commandButton action="{!URLFOR($Action.Contact.NewContact)}" value="New Contact" />
        </apex:pageBlock>
    </apex:form>
</apex:page>

This works fine when I preview the page outside the console. but when I add this page to the sidebar of the case, it throws the following error:

Id value 500K000000DpHSy is not valid for the Contact standard controller

below is the screenshot of the console sidebar,and Screenshot of the preview.

enter image description here enter image description here

2
  • what does the ID correspond to, is it a case record id?
    – glls
    Commented May 9, 2017 at 16:49
  • @glls Yes it is a case record id
    – Ricky
    Commented May 9, 2017 at 16:51

2 Answers 2

5

You simply need to change the standardController attribute on your <apex:page> tag to Case:

<apex:page standardController="Case">
    <!-- other markup -->
</apex:page>

If you didn't know 500 were the Case key prefix, note you can always figure out the SObjectType of a given Id by dropping the key prefix (first three digits) into a script like the following:

system.debug(Id.valueOf('500'.rightPad(15, '0')).getSObjectType());
1

When you try to expose the visualforce at Sidebar, it will look for StandardController as "Case" and not Contact, since this console layout is specific to Case record.

<apex:page standardController="Case">
    <apex:form >
    <apex:pageBlock >
        <apex:commandButton action="{!URLFOR($Action.Contact.NewContact)}" value="New Contact" />
    </apex:pageBlock>
    </apex:form>
</apex:page>

You need to properly manage the height% to display that.

You must log in to answer this question.

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