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
PhanidraPhanidra 

Unable to Create record of ApexPage type

following in my simple Apex class where am Trying to insert ApexPage Record, but am getting 'DML not Allowed on ApexPage', can any one help me on this please

 

public class test{
   public void createPage(){
       List<ApexPage> pageList = new List<ApexPage>();
        pageList.add(new ApexPage(Name = DynamicPageCreation,
                                                           Markup = <apex:page>Test Success</apex:page>,
                                                              ApiVersion = 27.0,
                                                      MasterLabel = DynamicPageCreation) );
         insert pageList;
     }
}

 

Thanks in Advance,

Phani

 

 

Saurabh DhobleSaurabh Dhoble

I think you've got the concept wrong here - the ApexPage class is available for creation via the Salesforce API - you cannot create it via Apex code.

 

Look at this link - you can write the sample code in Java/C# to create an apex page programatically. However, writing Apex code to create a VF page looks highly improbable - it's as if you were trying to create custom objects via Apex code, which is not permissible as far as I know.