1

Is there anyway to include an input box in the home custom components, preferably at left hand side panel of the salesforce.

Updated after Dan's comment: Following is the code I am using.

<apex:page showHeader="false" sidebar="false" standardController="ScorecardConfig__c">
  <apex:form >
    <apex:pageBlock title="Penetration threshold">
      <apex:pageBlockButtons >
        <apex:commandButton action="{!Save}" value="Save" />
        <apex:commandButton action="{!Cancel}" value="Cancel" />
      </apex:pageBlockButtons>
      <apex:inputField value="{!ScorecardConfig__c.Independent_CP_penetration_threshold__c}" label="Ind CP"/>
      <apex:inputField value="{!ScorecardConfig__c.NEC_CP_penetration_threshold__c}" label="NEC CP"/>
    </apex:pageBlock>
  </apex:form>
</apex:page>
1
  • It is possible, But it requires you to develop a custom VF page. There you can include an input box.
    – Anujit Das
    Apr 18, 2017 at 11:36

1 Answer 1

2

Yes. You'd need to create a Visualforce Page and use a Standard Controller or Custom Controller to perform the logic you want, then you can include that page as a component in the sidebar. The Page doesn't need to be special, something like this would be enough:

<apex:page showHeader="false" sidebar="false" standardController="My_Object__c">
  <apex:form>
    <apex:pageBlock>
      <apex:pageBlockButtons>
        <apex:commandButton action="{!Save}" value="Save" />
        <apex:commandButton action="{!Cancel}" value="Cancel" />
      </apex:pageBlockButtons>
      <apex:inputField value="{!My_Object__c.My_First_Field__c}" />
      <apex:inputField value="{!My_Object__c.My_Second_Field__c}" />
      <apex:inputField value="{!My_Object__c.My_Last_Field__c}" />
    </apex:pageBlock>
  </apex:form>
</apex:page>

Obviously this is just a standard Visualforce Page, nothing fancy.

Step 1

Start by going to:

Setup > Customise > Home > Home Page Components

Under Custom Components, click New, give it a name and choose Visualforce Area.

Select the Component Position you want, probably Narrow (Left) Column and select your Visualforce Page from the list. You'll then, set the height (in pixels) and then select if you want to have a scrollbar (in case of Overflow) and if you want to display the label.

Step 2

Finally, you'll need to add it to the relevant Home Page Layout. To do this, go to:

Setup > Customise > Home > Home Page Layouts

Press Edit next to the Layout you want to include the component for, then select the checkbox next to the component you created in Step 1.

10
  • Thanks Dan. But how to pass the value from 'My_Object__c.My_First_Field__c' to the apex class so that when sforce.apex.execute("RestClient", "mymethod", {}); executes it send the 'My_First_Field__c' value to the mymethod (which is in my apex class)
    – Gagan
    Apr 19, 2017 at 4:47
  • I guess what you were saying is, that after clicking the Save button on the Visualforce page the value gets stored in the custom object. Then I will write a logic at my end to retrieve the value from that object and use it wherever i want. Please correct me if i am wrong.
    – Gagan
    Apr 19, 2017 at 6:29
  • @Gagan That depends on what it is your doing. If all you're doing is creating records, something akin to the Visualforce Page would do. If you use a Standard Controller as the example shows, you'll be able to use standard actions such as Save, Cancel, Edit etc... But you're right, you could create a record and execute an action of the back of that to make a REST callout.
    – Dan Jones
    Apr 19, 2017 at 7:56
  • I have done whatever was mentioned in the above post but i am stuck at a point. In my home page layout, i have added the visualforce page. But it not showing the input fields rather the apex code you mentioned above. Or in other words, it is not showing the preview of the code but the code itself. Anything i am missing?
    – Gagan
    Apr 19, 2017 at 14:52
  • @Gagan Can you include your code in your question? Just edit it above.
    – Dan Jones
    Apr 19, 2017 at 15:12

You must log in to answer this question.

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