Illegal arguments unexpected error when overriding new custom object.

  • 1
  • Problem
  • Updated 4 years ago
I'm testing Skuid in an org with namespace "skuidtest1" and I'm following the tutorial to create a simple page to override the new action of a custom object and I get the error "Illegal arguments" when attempting to create a new custom object (skuidtest1__Estado__c).

- The custom object has the new action overriden with the VF page: EstadoNew
- The vf page EstadoNew has the following markup:

<apex:page standardController="Estado__c" extensions="skuid.Redirects" action="{!redirect}?page=EstadoNew"/>

- And the Skuid page EstadoNew has the following xml:

<skuidpage unsavedchangeswarning="yes" showsidebar="true" showheader="true" tabtooverride="skuidtest1__Estado__c">   <models>
      <model id="Estado" limit="1" query="false" createrowifnonefound="true" sobject="skuidtest1__Estado__c">
         <fields>
            <field id="Name"/>
            <field id="skuidtest1__Abreviacion__c"/>
         </fields>
         <conditions/>
         <actions/>
      </model>
   </models>
   <components>
      <pagetitle model="Estado">
         <subtitle>Nuevo estado</subtitle>
         <actions>
            <action type="savecancel" afterCancel="/{{Model.KeyPrefix}}/o" afterSave="/{{Id}}" rollbackonanyerror="true"/>
         </actions>
         <maintitle>{{Name}}</maintitle>
      </pagetitle>
      <basicfieldeditor showsavecancel="false" showheader="true" model="Estado" mode="edit">
         <columns>
            <column width="50%">
               <sections>
                  <section title="Información de estado" collapsible="no">
                     <fields>
                        <field id="Name" required="true"/>
                        <field id="skuidtest1__Abreviacion__c"/>
                     </fields>
                  </section>
               </sections>
            </column>
            <column width="50%">
               <sections/>
            </column>
         </columns>
      </basicfieldeditor>
   </components>
   <resources>
      <labels/>
      <css/>
      <javascript/>
   </resources>
</skuidpage>

What am I missing?
Photo of Sebastian Canseco

Sebastian Canseco

  • 358 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
When you look at your URL, do you see two question marks?  If so change the "?" in your VF code to be a "&"
Photo of Sebastian Canseco

Sebastian Canseco

  • 358 Points 250 badge 2x thumb
Rob the URL result of clicking the New button is:

https://skuidtest1.na17.visual.force.com/apex/EstadoNew?retURL=%2Fa09%2Fo&amp;save_new=1&amp;sfdc.override=1

I've tried with VF code:
<apex:page standardController="Estado__c" extensions="skuid.Redirects" action="{!redirect}?page=EstadoNew"/>

And with:
<apex:page standardController="Estado__c" extensions="skuid.Redirects" action="{!redirect}&page=EstadoNew"/>

Both with the same error result. 
(Edited)
Photo of Sebastian Canseco

Sebastian Canseco

  • 358 Points 250 badge 2x thumb
It seems that the problem is with the namespace, since I've tried a very weird mix:

<apex:page standardController="Contact" extensions="skuid.Redirects" action="{!redirect}?page=EstadoNew"/>

And the New button works correctly although obviously won't work when saving changes since the page's model (skuidtest1__Estado__c) doesn't relate to the standadardController (Contact).

I have tried writing the full custom object including the namespace in the standardController attribute:

<apex:page standardController="skuidtest1__Estado__c" extensions="skuid.Redirects" action="{!redirect}?page=EstadoNew"/>

But when saving the page Salesforce automatically removes the namespace.
Photo of Sebastian Canseco

Sebastian Canseco

  • 358 Points 250 badge 2x thumb
This is what did work, I changed the VF page to:

<apex:page controller="skuid.Redirects" action="{!redirect}&page=EstadoEdit"/>

I found this solution in a earlier post:

https://community.skuidify.com/skuid/topics/visualforce_page_not_listed_when_overriding_tab?topic-re...

I do have a namespace in the current org but no managed package. I guess this is the way to go for namespaced orgs.

Thanks!
Photo of Sebastian Canseco

Sebastian Canseco

  • 358 Points 250 badge 2x thumb
Altough another issue with this is when creating pages to override Tabs. Since the attribute recordSetVar needs the standardController attribute, then we are back where we started:

<apex:page standardcontroller="Estado__c" extensions="skuid.Redirects" recordSetVar="e" action="{!redirect}&page=EstadoTab"/>

And this doesn't work. So, how should I do to use recordSetVar and controller="skuid.Redirects" ?
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
You actually don't need recordSetVar in order to override Tab pages. Just do:

<apex:page controller="skuid.Redirects" action="{!redirect}&page=EstadoTab"/>

or 

<apex:page readonly="true" doctype="html-5.0">
   <skuid:page page="EstadoTab"/>
</apex:page>
Photo of Sebastian Canseco

Sebastian Canseco

  • 358 Points 250 badge 2x thumb
I was following this tutorial where it says I need recordSetVar:

http://help.skuidify.com/m/getting-started/l/102647-override-a-standard-salesforce-tab-page-layout

But I'm really glad you keep having these "Ace" cards under the sleeve. Thanks for saving the day again!
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Yes, unfortunately the Visualforce overrides are more complicated on Managed Package objects. Most of our users don't run into this, and so I think we've tried to keep it simple, at the expense of covering all of the edge case scenarios.
Photo of Sebastian Canseco

Sebastian Canseco

  • 358 Points 250 badge 2x thumb
So in order to deploy my work to the Packaging org (namespaced as well) I should stick to this alternative right? And just replace all skuidtest1 namespace occurrences in staticResources for the packaging org namespace correct?
Photo of Sebastian Canseco

Sebastian Canseco

  • 358 Points 250 badge 2x thumb
Just a further insight on this because I realized that apparently neither this code:
<apex:page standardcontroller="Estado__c" extensions="skuid.Redirects" action="{!redirect}&page=EstadoNew"/>

nor this code:
<apex:page controller="skuid.Redirects" action="{!redirect}&page=EstadoNew"/>

worked as expected.

The first one has the little disadvantage that throws an unexpected error because of illegal arguments when running the page (I think is because standardController attribute doesn't have the namespace and trying to add it manually won't work beacuse SF will remove it automatically so standardcontroller="namepsace__Estado__c" will turn into standardcontroller="Estado__c" when saving the changes).

The second one does work but has the disadvantage that it doesn't get listed in the Custom Object action override page i.e. Setup/Create/MyCustomObject/Buttons, Links, and Actions (I think this is because the code doesn't refer to the custom object anywhere).

So what ended up working was this third option as Zach suggested:
<apex:page standardController="Estado__c" readonly="true" doctype="html-5.0">
   <skuid:page page="EstadoEdit"/>
</apex:page>
But I had to add the standardController attribute. This way it works as expected while running the page and the VF page does get listed in the override actions page as well.

To finish, and to avoid getting confused as me with different code alternatives, you can use this same code for View, Edit, New and Tab actions, with the note that Tab will need that you add the attribute recordSetVar:
<apex:page standardController="Estado__c" recordSetVar="e" readonly="true" doctype="html-5.0">   
<skuid:page page="EstadoTab"/>
</apex:page>

I hope this helps other developer bros.

PS. If you find this not accurate please let me know.
(Edited)