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
herodotusherodotus 

HOWTO Upload Custom Button to a Custom Object Using ANT - Anyone figured this out?

Has anyone managed to deploy a custom javascript button using ANT.

After looking around a bit I can't find any help on this.


An example with package.xml, and the object xml would be much appreciated, as would any pointers on where to look to figure this out.

 

For example, in package.xml, what name do we use in Package/types/name markup. CustomObject?

If CustomObject is correct, what markup should be in the customobject.object file in the objects directory?

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
herodotusherodotus

After a bit of poking around it turns out that the buttons are called WebLinks.

 

In package.xml put a section like:

<Package>

<types>

<members>objectname.buttonnamegoeshere</members>

<name>WebLink</name>

</type>

</Package>

 

then put the object in the objects directory.

 

In the objectname.object file, put the button setup into a section like

<CustomObject>

<webLinks>

 

        <fullName>New_From_Opportunity</fullName>
        <availability>online</availability>
        <displayType>massActionButton</displayType>
        <linkType>javascript</linkType>
        <masterLabel>New From Opportunity</masterLabel>
        <openType>onClickJavaScript</openType>
        <protected>false</protected>
        <url>window.location.href=&apos;/apex/CreditAppExtension?returl=%2F{!Opportunity.Id}&amp;launchId={!Opportunity.AccountId }&amp;launchMode=newFromOpportunity&amp;oppId={!Opportunity.Id}&apos;;</url>

 

         <fullName>buttonnamegoeshere</fullName> 

<availability>online</availability>

<displayType>massActionButton</displayType>

<linkType>javascript</linkType>

<masterLabel>Button Lable Goes Here</masterLabel>

<openType>onClickJavaScript</openType>

<protected>false</protected>

<url>window.location.href=&apos;/apex/CreditAppExtension?returl=%2F{!Opportunity.Id}&amp;launchId={!Opportunity.AccountId }&amp;launchMode=newFromOpportunity&amp;oppId={!Opportunity.Id}&apos;;</url>

 

</webLinks>

 

        <fullName>New_From_Opportunity</fullName>
        <availability>online</availability>
        <displayType>massActionButton</displayType>
        <linkType>javascript</linkType>
        <masterLabel>New From Opportunity</masterLabel>
        <openType>onClickJavaScript</openType>
        <protected>false</protected>
        <url>window.location.href=&apos;/apex/CreditAppExtension?returl=%2F{!Opportunity.Id}&amp;launchId={!Opportunity.AccountId }&amp;launchMode=newFromOpportunity&amp;oppId={!Opportunity.Id}&apos;;</url>

</CustomObject>

 

The java script goes in the url section.

 

 

All Answers

herodotusherodotus

After a bit of poking around it turns out that the buttons are called WebLinks.

 

In package.xml put a section like:

<Package>

<types>

<members>objectname.buttonnamegoeshere</members>

<name>WebLink</name>

</type>

</Package>

 

then put the object in the objects directory.

 

In the objectname.object file, put the button setup into a section like

<CustomObject>

<webLinks>

 

        <fullName>New_From_Opportunity</fullName>
        <availability>online</availability>
        <displayType>massActionButton</displayType>
        <linkType>javascript</linkType>
        <masterLabel>New From Opportunity</masterLabel>
        <openType>onClickJavaScript</openType>
        <protected>false</protected>
        <url>window.location.href=&apos;/apex/CreditAppExtension?returl=%2F{!Opportunity.Id}&amp;launchId={!Opportunity.AccountId }&amp;launchMode=newFromOpportunity&amp;oppId={!Opportunity.Id}&apos;;</url>

 

         <fullName>buttonnamegoeshere</fullName> 

<availability>online</availability>

<displayType>massActionButton</displayType>

<linkType>javascript</linkType>

<masterLabel>Button Lable Goes Here</masterLabel>

<openType>onClickJavaScript</openType>

<protected>false</protected>

<url>window.location.href=&apos;/apex/CreditAppExtension?returl=%2F{!Opportunity.Id}&amp;launchId={!Opportunity.AccountId }&amp;launchMode=newFromOpportunity&amp;oppId={!Opportunity.Id}&apos;;</url>

 

</webLinks>

 

        <fullName>New_From_Opportunity</fullName>
        <availability>online</availability>
        <displayType>massActionButton</displayType>
        <linkType>javascript</linkType>
        <masterLabel>New From Opportunity</masterLabel>
        <openType>onClickJavaScript</openType>
        <protected>false</protected>
        <url>window.location.href=&apos;/apex/CreditAppExtension?returl=%2F{!Opportunity.Id}&amp;launchId={!Opportunity.AccountId }&amp;launchMode=newFromOpportunity&amp;oppId={!Opportunity.Id}&apos;;</url>

</CustomObject>

 

The java script goes in the url section.

 

 

This was selected as the best answer
Force.comForce.com

Thanks for the solution. It saved my time.