• Lokesh Lokesh Malviya
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi,
Belew is the VF page and controller using the metadata methods.And there are two errors:
-->Method does not exist or incorrect signature: void createService() from the type MetadataController
--->Variable does not exist: customField

<apex:page controller="MetadataController">
    <apex:form id="form">
        <apex:sectionHeader title="Metadata Demo">
            <apex:pageMessages/>
                <apex:actionPoller action="{!checkStatus}" interval="5" rerender="form" rendered="{!NOT(ISNULL(Result))}">
                    <apex:outputPanel rendered="{!ISNULL(Result)}">
                        <apex:commandButton value="Create Field" action="{!createField}"/>
                        <!--apex:commandButton value="Delete Field" action="{!deleteField}"/-->
                    </apex:outputPanel>
                </apex:actionPoller>
        </apex:sectionHeader>
    </apex:form>
</apex:page>
--------------------------------------------------------------
public with sharing class MetadataController {
    
    public MetadataService.AsyncResult result {get;set;}
    public Book__c b{get;set;}
    
    public MetadataController(){
    
        result = new MetadataService.AsyncResult();        
    }
    
    
    public PageReference createField()
    {
        // .. as per above ...
        result = createService().create(new List<MetadataService.Metadata>{customField})[0];
        displayStatus();
        return null;
    }
    
    public PageReference checkStatus()
    {
        // Check status of the request
        //result = createService().checkStatus(new List<String> { result.Id })[0];
        displayStatus();
        return null;
    }
    
    private void displayStatus()
    {
        // Inspect the AsyncResult and display the result
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,
                                                   result.done ? 'Request completed' : 'Request in progress...'));
        if(result.state == 'Error')
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, result.message));
        if(result.done)
            result = null;
    }
}
Can someone help me

Thanks in Advance