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
LegerdemainLegerdemain 

Custom list button using standard controller | error: Invalid variant 'parent': value 'Account'

Hi fellow developers,

I'm trying to emulate the sample in the vf dev guide (Adding Custom List Buttons using Standard List Controllers), but with a twist: using a detail from a master-detail (Account = Master, detail = Flavor_Request__c).

I have both the Apex Class and controller similar to the example in the dev guide:

Code:
public class OpptyFlavorListButton
{
    public OpptyFlavorListButton(ApexPages.StandardSetController controller) {
            controller.setPageSize(10);
    }
}

<apex:page standardController="Flavor_Request__c" recordSetVar="flavors"
    tabStyle="Flavor_Request__c" extensions="OpptyFlavorListButton">
<apex:form >
    <apex:pageBlock title="Edit Status" mode="edit">
        <apex:pageMessages />
        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>

        <apex:pageBlockTable value="{!selected}" var="f">
            <apex:column value="{!f.name}"/>
            <apex:column value="{!f.Request_Type__c}"/>
            <apex:column value="{!f.Sample_Size__c}"/>
            <apex:column headerValue="Status">
                <apex:inputField value="{!f.Status__c}"/>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

 



The buttons are added to the appropriate layouts, however, I keep getting the following errors:
1. Invalid variant 'parent': value 'Account'
2. Invalid variant 'parent': value 'Opportunity'

I get error #1 when trying this from the Account page (related list of flavors)
I get error #2 when trying this from the Opportunity page (related list of flavors)

I'm hitting these errors as the System Administrator who wrote the code...

Any feedback/suggestions would greatly be appreciated.

Thanks,
Larry


Message Edited by Legerdemain on 12-04-2008 08:38 PM

Message Edited by Legerdemain on 12-04-2008 08:39 PM
LegerdemainLegerdemain
Ok - I found out that the standard objects have implicit definitions for what a "Parent" is. Since custom objects may have lookup and master-detail relationships, "Parent" is not implicitly defined.

I passed in the parent through the button... (URL)
apex/[VF page]?parent={!CustomObject.Customfield_ID__c}

Cheers,
Larry
devNut!devNut!
Hey,
So, in your custom button did you use "Content Source" as "URL" ?

With the URL being:
https://<server>.salesforce.com/apex/<pageName>?parent=
{!CustomObject.Customfield_ID__c}



Thanks
JeremyKraybillJeremyKraybill

Hi, I am running into this same issue. I am trying to add a normal StandardSetController extension-backed VF page as a list button for a record which is the "detail" in a master-detail relationship in which Account is the "master".

 

When I activate this button in the Account layout on the related list, as soon as clicking the button I get the following error on the screen, which is thrown before the code even enters the controller's constructor:

Invalid variant 'parent': value 'Account'

No administrator email exception notification is sent.

 

I have done this exact same thing in several other places, except that the related list object I activated the button on was not the detail of a master-detail relationship.

 

The solution listed here, passing a "parent" parameter, does indeed prevent the above error from occurring for me, but of course this loses the advantage of using a StandardSetController with list checkboxes: I need to capture the records that the user checked off before clicking the button.

 

Is this a SF bug? Is there any solution that allows me to link the related list button (with checkbox selections intact) to a VF page that doesn't involve a hack like invoking an S-Control which passes the ID's to the VF page via page parameters?

 

Any help much appreciated.

 

Jeremy Kraybill

Austin, TX

 

JeremyKraybillJeremyKraybill

Update: a few clarifications to the above.

 

- this does not appear to be specific to related lists of master-detail records; I have been able to reproduce it in buttons for both detail and non-detail records in related lists on the Account and Opportunity pages.

 

-  contrary to what I wrote, I actually realized that the multi-select buttons we have on related lists right now are not bound to VF pages, they are bound to S-Controls. We do have several list buttons backed by VF pages, but they are all used in standard views, not related lists.

 

Any help much appreciated!

 

Jeremy Kraybill

Austin, TX

dchasmandchasman

Not sure if I am understanding you exactly but I had not trouble wiring up this page:

 

 

<apex:page standardController="Contact" recordSetVar="contacts"> <apex:pageBlock > <apex:pageBlockTable var="contact" value="{!selected}"> <apex:column value="{!contact.name}"/> <apex:column value="{!contact.account.name}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>

 

 

to a custom list button on Contact that I then added to the Account's contact related list layout button set (with multiselect checkbox display enabled for the button of course) and my VF page as the target metadefinition. I am able to perform an operations on the selected set of contacts.

 

Is this not what you are trying to accomplish?

Message Edited by dchasman on 01-24-2009 08:47 AM
JeremyKraybillJeremyKraybill

Doug, indeed, I was able to successfully wire up the page you describe here. However as a base repro, I was able to make a simple custom object and reuse your code to repro the error.

 

- created a new custom object called "DeleteMe"

- gave it one custom field, just a lookup to Account called "Account__c"

- created a VF page based on yours:

 

<apex:page standardController="DeleteMe__c" recordSetVar="dms"> <apex:pageBlock > <apex:pageBlockTable var="dm" value="{!selected}"> <apex:column value="{!dm.Name}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>

 

- added a custom list button to DeleteMe with this page as the content

- added this button to the related DeleteMe list on the Account page layout

 

Now when I select at least one DeleteMe with a checkbox, then click on the custom button, I get the "Invalid variant 'parent': value 'Account'" as the page content in a page whose title says "VisualForce Error".

 

Based on this it appears this would affect any custom list button on a related list to a custom object.

 

Any help or workarounds much appreciated.

 

Jeremy Kraybill

Austin, TX

 

JeremyKraybillJeremyKraybill

Bumping this thread as we have not been able to successfully resolve it yet. For now my only workaround is going to be to move this to a detail page button instead of a list button.

 

Doug, any ideas?

 

Other developers, anyone run into this or solved it?

 

Any help much appreciated.

 

Jeremy Kraybill

Austin, TX

MVBobMVBob

I get this same error message when I use the example in the Visualforce Developer's Guide on the page for Editing a Table of Data in a Page.

 

- Without an account id in the url I get "'00530000000kaBD') AND (Over_90__c > 0.0) or (Over_120__c > 0.0)) ORDER BY ^ ERROR at Row:1:Column:98 expecting a right parentheses, found 'or'"

 

- With an account id in the url I get "Invalid variant 'parent': value 'Account'"

 

The sample code from the Guide is:

<apex:page standardController="Account" recordSetVar="accounts" 
   tabstyle="account" sidebar="false">
   <apex:form> 
   <apex:pageBlock >
   <apex:pageMessages />
   <apex:pageBlockButtons>
      <apex:commandButton value="Save" action="{!save}"/>
   </apex:pageBlockButtons>

   <apex:pageBlockTable value="{!accounts}" var="a">
      <apex:column value="{!a.name}"/>
      
      <apex:column headerValue="Service Level Agreement">
         <apex:inputField value="{!a.sla__c}"/>
      </apex:column>

   </apex:pageBlockTable>
   </apex:pageBlock>
   </apex:form>
</apex:page>

The sample code uses a field called "sla". Since this was not in our installation, I tried using another picklist field.

 

Is the sample incorrect or am I making an error?

 

Thanks.

cpo87cpo87

Hi Larry,

 

I have run into the same problem you had however after attempting the fix you implemented I am still receiving the error.  Can you clarify the last part of the URL "parent={!CustomObject.Customfield_ID__c}"?

 

I am assuming that 'CustomObject' is referring to the name of the related list object and 'Customfield_ID__c' is referring to the field on the related list object that links to the parent object, in my case a lookup field.  Am I correct in this assumption?  I have tried this and so far I am still receiving this error.

 

Please assist,

 

Christian

PSteves91PSteves91

I've run into this same issue. Is there an update on a fix?

 

My scenario is as follows:

 

I've created a custom object that links open Cases to Products to capture information that details what specific issues a customer has with our product(s). It is possible that a case could have more than one related product. So, 'Case --> Related Products <-- Product'.

 

Instead of having or agents manually update every product in the related list, we would like them to update the Related Product(s) all at once. Using mass actions seems to be the solution to our problem.

 

In the Salesforce Force.com Developer's Guide, Mass Actions is demonstrated as being used with two custom objects, Positions and Job Applications. When we apply this logic to our scenario, we get the following error:
Invalid variant 'parent': value 'Case', which seems to run along the lines of this discussion.

 

Any feedback on a possible solution would be helpful.

 

Thanks!

 

 

MarkL.ax269MarkL.ax269
"Based on this it appears this would affect any custom list button on a related list to a custom object."

I would agree with this statement. Got the same issue just now. However I cheated by creating the list button and setting to the VF page, then removing the recordSetVars and the constructor with the list controller (left the standard constructor alone) and the button works. So if you don't need the list controller (and I don't) then this might be a workaround.
CTU007CTU007

Hi, I just installed the "Mass update and Mass edit" from appexchange, and added the "mass edit" button to a related list on opportunity, and got this error.

 

So is there any solution to this?

 

CTU007CTU007

I used Larry's code:

 

 /apex/[VF page]?parent={!CustomObject.Customfield_ID__c}

 

It worked, but I got a nested salesfore.com window, and after I save changes to the child records, it does not return to the opportunity I worked with, but to my home page.

 

 

 

 

returned to home after save:

 

 

CTU007CTU007

I did some test by changing the URL from:

 

 

/apex/[VF page]?parent={!CustomObject.Customfield_ID__c}

 

 

 

to:

 

/apex/[VF page]?sdtp=mn

 

 

And it removed the nested frame when I edit the selected records, but the URL displayed is still the opportunity link, and after I save, it returns to the home page with the nested frame.

 

I also tried to add:

 

 

&retURL=%2Fapex/tabbedoppall?id=&sfdc.override=1

 to the URL so it can return to the opportunity, but it cannot work.

 

anyone can help?

 

Thanks.

 

 

 

 

CTU007CTU007

I guess I know why it cannot go back to the opportunity page.

 

Since the edit is on child objects from the list view, it cannot get the parent.id from those records/array, so it cannot go back to the opportunity.

 

Any suggestion on how to go back to the parent record?

 

I checked the masseditopp on account related list, I can see when I click the button, the URL becomes:

 

 

https://ssl.salesforce.com/apex/MassEditOpp?retURL=%2Fapex%2Ftabbedaccount%3Fcore.apexpages.devmode.url%3D1%26id%3D00100000001tT1u%26sfdc.override%3D1&wrapMassAction=1&scontrolCaching=1&id=00100000001tT1u

 

 So why it can work on standard object?

 

Help, please!!!

 

 

 

RalphCallaway.ax615RalphCallaway.ax615

Please log a case with saleforce support if you encounter similar issues.

 

In the case comments reference this as a possible instance of bug W-672711. 

RalphCallaway.ax615RalphCallaway.ax615

If you are experiencing this issue, please log a case with saleforce support.

 

In the case comments reference this as a possible instance of bug W-672711. 

CTU007CTU007

Hi, Ralph, any update from salesforce on this to you? What happened to your case?

 

I am still struggling with the return URL.... I need it return to the page where the button was clicked.

SteveBowerSteveBower

 

BUMP.

 

I have the same problem.  I contacted support and asked for the status of Bug number W-672711.  The support guy was unable to find such a bug in their system.  Not open, closed, etc.  He just didn't find that number at all.

Since I suspect Ralph Callaway didn't just make up this number, I don't know what's going on.

 

Thanks, Steve.

sparkysparky

Here's yet another vote for someone at SF figuring this out.  I posted on this several months ago, submitted a case, no resolution.

 

Memo to SF: we appreciate you guys, we really do, and we love it when SF employees show up here on the forums and try to help us out.  And many times you do help us out.  But we'd love it a lot more if you wouldn't show up, ask a few questions, and then leave us hanging, or give us info which doesn't pan out, then neglect to help further.  Just sayin', ok?  Peace.

fmarkfmark

I have a similar problem.

I have a related list called Files (A custom object) on an opportunities record. I want to update a field on a number of file records.

 

I have created a Custom List button that oints to the following visualforce page

<apex:page standardController="File__c" recordSetVar="files">
    <apex:sectionHeader title="Mass Export Files to Network Folder"/>
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Change" collapsible="false">
                <apex:inputField value="{!File__c.File_description__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Selected Files" columns="1">
                <apex:pageBlockTable value="{!selected}" var="file">
                    <apex:column value="{!File__c.name}"/>
                    <apex:column value="{!File__c.File_description__c}"/>                        
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    </apex:page>

 

On selecting items from the related list I get the following message:  Invalid variant 'parent':Opportunity. I will raise a further case to see if there is a resolution to this

 

Where are all the smiley faces coming from???!!!"!"

Message Edited by fmark on 02-22-2010 05:31 AM
SteveBowerSteveBower

This is still an issue.   I've unmarked it as having a solution.

 

If you filed a case about this, could you post the case number so others can either "pile in" or track the resolution? 

fmarkfmark
I have raised case number 03332481
Message Edited by fmark on 02-22-2010 10:19 PM
Message Edited by fmark on 02-22-2010 10:20 PM
SteveBowerSteveBower
Support got back to me and said this bug was closed as a known issue that the developers are working on.  Expectation is that it will be released as a patch and not wait for a major release.  Couldn't give me a days/weeks/months timeframe.