function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
WycadoWycado 

Adding "Create New" button to my VF page

I created a VF page that I am using on a custom Tab to show "Assets", which has no standard Tab. It works fine, but I want to add the capability to create a new Asset from my Asset view. I've reached my limit of apex ability. Any help on adding to the code below to create a "New Asset" button on my page would be most appreciated. 

 

<apex:page standardController="Asset">
<apex:enhancedList type="Asset" height="700" rowsPerPage="50" id="AllAssets"></apex:enhancedList>
</apex:page>
              
Best Answer chosen by Admin (Salesforce Developers) 
Satish_SFDCSatish_SFDC
<apex:page standardController="Asset">
<apex:form >
   <apex:commandButton value="Create New Asset" action="https://<instance>.salesforce.com/02i/e"/>
</apex:form>
<apex:enhancedList type="Asset" height="700" rowsPerPage="50" id="AllAssets" />
</apex:page>

 

Type your instance (eg: cs8,na1 etc).

This is just a quick fix. Another approach is to use a controller extension to get the new asset page dynamically without hardcoding the instance.

 

 

Regards,
Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.

 

All Answers

Satish_SFDCSatish_SFDC
<apex:page standardController="Asset">
<apex:form >
   <apex:commandButton value="Create New Asset" action="https://<instance>.salesforce.com/02i/e"/>
</apex:form>
<apex:enhancedList type="Asset" height="700" rowsPerPage="50" id="AllAssets" />
</apex:page>

 

Type your instance (eg: cs8,na1 etc).

This is just a quick fix. Another approach is to use a controller extension to get the new asset page dynamically without hardcoding the instance.

 

 

Regards,
Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.

 

This was selected as the best answer
WycadoWycado

Most Excellent. Thank you!!