1

I am implementing Case Feed and want to add an object specific Publisher Action "New Contact". I understand that this should be with a Visualforce page but am not sure how . . . Also, the newly created Contact should be linked to the Case.

Fields: -Account Name (prepopulated - either with default value or via lookup to a custom field on the user object {! $User.Default_Account__c} ) -First name -Last Name -Email Address -Phone number

Here is my very first attempt at a Visualforce page . . . which works in the Visualforce preview window, but fails when launched from the Publisher Action. Can anyone offer any pointers . . . ?

<apex:form >

<apex:pageBlock >
    <apex:pageBlockSection columns="1">
        <apex:inputField value="{!contact.AccountID}" />
        <apex:inputField value="{!contact.FirstName}" />
        <apex:inputField value="{!contact.LastName}" />
        <apex:inputField value="{!contact.email}" />
        <apex:inputField value="{!contact.phone}" />
    </apex:pageBlockSection>

    var contact.AccountId = "{! $User.Default_SARMS_Account__c }";

    <apex:pageBlockButtons >
        <apex:commandButton action="{!save}" value="Save"/>
    </apex:pageBlockButtons>
</apex:pageBlock>    
</apex:form>

  • Could you post your controller exension as well? I would be happy to provide you with what you need to do. Also could you post your <apex:page> and all of its attributes as well? – TC Sutton Jun 10 '15 at 21:39
  • Hi. Yes, revealing my novice status here. Not sure how to write a controller extension (I normally live in the point and click world). My page begins simply . . . <apex:page docType="html-5.0" standardController="Contact" title="New Viewer"> – Andrew Hart Jun 10 '15 at 21:43
  • 2
    Not too familiar with case feeds, but publisher actions will only pass the ID from the object that the action button is placed on. You will then query the necessary fields to pre-populate your visualforce object, and once inserted you will then have a Contact.ID that is available for you to then save as the case.contact. developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/… – TC Sutton Jun 10 '15 at 22:19
  • Thanks Tim - that's a helpful resource for me to look at. – Andrew Hart Jun 10 '15 at 22:26
0

It doesn't look like you're doing anything here that requires Visualforce. Assuming that Contact has a lookup to Case (as you've specified), you might be able to create an object-specific Create a Record action on the Case object.

  1. Under the Case object, go to Buttons, Links and Actions.
  2. Click New Action
  3. Choose Create a Record, and Contact as the target object type.
  4. On the action layout, add the Account, Name, Email and Phone fields, and save the layout.
  5. On the action detail page, create predefined values for the Case field (using the ID field of the current case - the field doesn't have to be on the layout), Account (using $User.Default_Account__c), etc.
  6. Add the action to the page layout.

If you're using Visualforce, there is some work involved using publisher.js to use the publisher buttons instead of adding a Save button to the page.

  • Thanks shannonsans. I think is mis-spoke when I said "Contact should be linked to the Case" - I really should have been more specific and said that the Case should be linked to the Contact. Sorry for the red herring. – Andrew Hart Jun 12 '15 at 18:33
  • The reason I embarked on this route was that we were having many Cases created from email-to-case without a Contact. I first thought of putting a "Create Contact" object specific action in place but then decided that a better approach would be to create a Contact for every email-to-case instance where there was no contact with that email address in existence. This I achieved in a declarative manner with Process Builder and a Flow. – Andrew Hart Jun 22 '15 at 21:11

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.