Today we will show you how to create a custom button on your object that does the same as the New Shipment button from your related list.
The most usual use case for this is if you want to create 2 one click shipment buttons from a standard or custom object. One for a standard outbound shipment, and the other for a return shipment.
For this demo we will use the standard Case object. The first thing we need to do is make sure our Custom Address Source related lists already added to the page. If you haven’t set up your custom address sources for one click shipping please look at the documentation found on our docs page here: https://docs.zenkraft.com/usps/one-click-shipments
Once you have your two related lists on the page like so:
Click on the first button and copy the resultant URL
You should get something like this:
https://zkusps.xxxx.visual.force.com/apex/Wizard?CF00NE0000003lPgf=00001026&CF00NE0000003lPgf_lkid=500E000000VCQyo&scontrolCaching=1&retURL=%2F500E000000VCQyo&sfdc.override=1
Paste this URL somewhere you can get to it later on, we will need it.
Next go to Setup > Customize > Cases > Buttons, Links, and Actions
Click the “New Button or Link” button.
Enter a Label and Name. Select “Detail Page Button”. Under the Behaviour select “Display in existing window without sidebar or header.” Set the Content Source to be “URL”.
Remember the link you copied and put somewhere safe? Lets copy that and paste it into the text area.
There are three changes we need to make to the URL. Lets split out the URL so its easier to read. Every time you see the “&” or “?” press enter.
We should end up with something similar to this:
https://zkusps.na39.visual.force.com/apex/Wizard
?CF00NE0000003lPgf=00001026
&CF00NE0000003lPgf_lkid=500E000000VCQyo
&scontrolCaching=1
&retURL=%2F500E000000VCQyo
&sfdc.override=1
This is the point you need to insert a merge field.
The first one to replace is the “Case Number” of the Case object. In this example 00001026 will be replaced with this merge field{!Case.CaseNumber}
And the next two replacements of 500E000000VCQyo are the salesforce case ids, which are replaced with {!Case.Id} as you can see here.
Click save and you are done for this part.
The next step is to add this newly created button onto your case object. To do that navigate to any Case and click on Edit Layout.
Click on Buttons, and find the button you created earlier “Create USPS Shipment”, and drag it down into the Custom Buttons section.
Then click save.
Test out the button that has now appeared.
Hopefully that has now worked for you, and you can do the same steps to create the Create a Return USPS Shipment button, that linked to the second Custom Address Source button.
As always we are here to help so contact us for any queries.