2

I would like to use a visualforce page to send the ID's of selected Invoices to an external URL when a Custom button is clicked.

I created a custom button that redirects to a visualforce page, so far so good. But when I try to write a simple visualforce page with a standard controller on Invoice, i get the error "Invoice does not exist" when trying to save the page.

enter image description here

Below is the page code:

<apex:page standardController="Invoice" recordSetVar="invoices">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="../../soap/ajax/48.0/connection.js" type="text/javascript"></script>
    <script>
        var idArray = '{!selected}'.replace("[", "").replace("]", "").replace(" ", "").split(',');

        $(document).ready(function () {
            if (!!idArray && idArray.length > 0 && idArray[1].length > 0) {
                postData(idArray);
            } else {
                alert("Please select at least one record.");
            }
        });

        function postData(idArray) {
            ... ajax call goes here ...
        }
    </script>  
</apex:page>

Is it normal I can't use a standardcontroller for Invoice? The developer docs say there are standard controllers for all queryable objects:

Thanks in advance

  • 2
    Is the API version of the Visualforce page 48 or higher? Invoices were not added as a standard object until the last release according to the docs. There may be limitations around the object because it requires the Salesforce Order Management license and it is explicitly stated it is only available in Lightning Experience - meaning there may not be a standard controller for them in Visualforce. – nbrown Jun 3 at 15:42
  • Thanks for the info, I didn't realize this was such a recent addition – Maarten Van De Velde Jun 4 at 5:58
2

I didn't realize that Visualforce pages hava a target api version setting. As @nbrown suggests in his comment, Invoice was only added in api version48 and targetting my page to that version solved my problem.

| improve this answer | |

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.