• Sucharita Nandan
  • NEWBIE
  • 0 Points
  • Member since 2014
  • Salesforce Administrator and Developer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
Hi, i want show list of opportunitylineitem when i click one opportunity from list of opp related to one account but its not working

vf Page:
<apex:page  controller="HTMLtestCon" showHeader="true" sidebar="true">
    <script type="text/javascript">
        function accountOpp(){
            var recordid = '{!$currentpage.parameters.id}';
            Visualforce.remoting.Manager.invokeAction(
                '{!$RemoteAction.HTMLtestCon.loadOpps}',
                recordid,
                function(result, event){
                    if (event.status) {
                        for (var i = 0; i < result.length; i++) {
                            var resultName = result[i].Name;
                            document.getElementById("{!$Component.block.blockSection.firstItem.OpportunityName}").innerHTML +=  resultName +'<br/>';
                            var resultAmount = result[i].Amount;
                            document.getElementById(
                                "{!$Component.block.blockSection.secondItem.amount}"
                            ).innerHTML += resultAmount +'<br/>';
                            var resultCloseDate = new Date(result[i].CloseDate);
                            document.getElementById(
                                "{!$Component.block.blockSection.thirdItem.CloseDate}"
                            ).innerHTML += resultCloseDate +'<br/>';

                        }
                    } else if (event.type === 'exception') {
                        document.getElementById("responseErrors").innerHTML =
                            event.message + "<br/>\n<pre>" + event.where + "</pre>";
                    } else {
                        document.getElementById("responseErrors").innerHTML = event.message;
                    }
                },
                {escape: true}
             );

        }
        function oppLineItems(){
            var oppName = document.getElementById('OpportunityName').value;
            Visualforce.remoting.Manager.invokeAction(
                '{!$RemoteAction.HTMLtestCon.loadOPLI}',
                recordid,
                function(result, event){
                    if (event.status) {
                        for (var i = 0; i < result.length; i++) {
                            var resultName2 = result[i].Product2.Name;
                            document.getElementById("{!$Component.block2.blockSection2.firstItem2.Product2Name}").innerHTML +=  resultName2 +'<br/>';
                            var resultQuantity = result[i].Quantity;
                            document.getElementById(
                                "{!$Component.block2.blockSection2.secondItem2.Quantity}"
                            ).innerHTML += resultQuantity +'<br/>';
                            var resultUnitPrice = new Date(result[i].UnitPrice);
                            document.getElementById(
                                "{!$Component.block2.blockSection2.thirdItem2.UnitPrice}"
                            ).innerHTML += resultUnitPrice +'<br/>';

                        }
                    } else if (event.type === 'exception') {
                        document.getElementById("responseErrors").innerHTML =
                            event.message + "<br/>\n<pre>" + event.where + "</pre>";
                    } else {
                        document.getElementById("responseErrors").innerHTML = event.message;
                    }
                },
                {escape: true}
             );
        }
    </script>

    <button onclick="accountOpp()">Related Opps</button>
    <div id="responseErrors"></div>

    <apex:pageBlock id="block">
        <apex:pageBlockSection id="blockSection" columns="3">
            <apex:pageBlockSectionItem id="firstItem">
                <apex:outputLink id="OpportunityName"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem id="secondItem">
                <apex:outputText id="amount"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem id="thirdItem">
                <apex:outputText id = "CloseDate" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
    <apex:pageBlock id="block2">
        <apex:pageBlockSection id="blockSection2" columns="3">
            <apex:pageBlockSectionItem id="firstItem2">
                <apex:outputText  id="Product2Name"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem id="secondItem2">
                <apex:outputText id="Quantity"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem id="thirdItem2">
                <apex:outputText id = "UnitPrice" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>



controller:

public class HTMLtestCon {
 
    @RemoteAction
    public static List<Opportunity> loadOpps( id recordid){
        List<Opportunity> listOfOpps = new List<Opportunity>();
        listOfOpps = [ Select Id, Name, Account.Name, CloseDate, Amount, Type from Opportunity
                                        where AccountId =: recordid ];
        return listOfOpps;
    }

    @RemoteAction
    public static List<OpportunityLineItem> loadOPLI( String oppName ){
        List<OpportunityLineItem> listofOPLI = new List<OpportunityLineItem>();
        listofOPLI = [ Select Id, Product2.Id, TotalPrice, Quantity, Product2.ProductCode, UnitPrice,
                                                                Product2.Family, Product2.Name , OpportunityId from Opportunitylineitem
                                                                where OpportunityId =:oppName ];
        return listofOPLI;
    }

}

also i want to stop opportunity list multiple time when i am clicking related opp button.


User-added imageUser-added image
how can i disable next when there is the last page or disable previous when i am on the first page

this is my controller:
public with sharing class OppOPLiOffSetPagination {

public Opportunity opp { get;set; }
public Integer pageNumberOPLI = 0 ;
public List<opportunitylineitem> listOfOpli { get; set; }
private Integer pageSizeOPLI = 5;
public String oppId{ get;set; }

public OppOPLiOffSetPagination() {
this.opp = [ Select Id, Name, Account.Name, Amount
from Opportunity
where Id = :ApexPages.currentPage().getParameters().get('id')];
this.oppId = this.opp.Id;
this.listOfOpli = new List<opportunitylineitem>();

}

public PageReference opprtunityLIneitemList(){
queryOPLI();
return null;
}

private void queryOPLI(){
Integer OffsetSize = pageNumberOPLI *pageSizeOPLI;
String opliQuery = ' Select Product2.Id, TotalPrice, Quantity, Product2.ProductCode, UnitPrice,'+
                                    'Product2.Family, Product2.Name , OpportunityId from OpportunityLineItem'+
                                    ' where OpportunityId =:oppId limit ' + pageSizeOPLI + ' offset ' + OffsetSize;
        this.listOfOpli = Database.query(opliQuery);

}

public PageReference Next() {
pageNumberOPLI++;
queryOPLI();
//enableDisablePaginationLinks();
return null;
}

public PageReference Previous() {
pageNumberOPLI--;
if (pageNumberOPLI < 0)
return null;
queryOPLI();
return null;
}

}

and here is my page:
<apex:page showheader="true" sidebar="true" controller="OppOPLiOffSetPagination">
<apex:form>
<apex:pageblock title="Opportunity Detail">
<apex:pageblocksection>
<apex:outputtext label="Name" value="{!opp.Name}"/>
<apex:outputtext label="Amount" value="{!opp.Amount}"/>
<apex:outputtext label="Account Name" value="{!opp.Account.Name}"/>
</apex:pageblocksection>
</apex:pageblock>
<apex:pageblock id="pgBlock">
<apex:pageblockbuttons>
<apex:commandbutton action="{!opprtunityLIneitemList}" value="Show Opps" rerender="pgBlock"/>
</apex:pageblockbuttons>
<apex:pageblocktable title="OPLI Detail" value="{!listOfOpli}" var="opli" id="pgTable">
<apex:column value="{!opli.Product2.Id}"/>
<apex:column value="{!opli.TotalPrice}"/>
<apex:column value="{!opli.Quantity}"/>
<apex:column value="{!opli.UnitPrice}"/>
<apex:column value="{!opli.Product2.Name}"/>
</apex:pageblocktable>
<apex:pageblockbuttons>
<apex:commandbutton value="Previous" action="{!Previous}" rerender="pgTable,pgBlock" status="status"/>
<apex:commandbutton value="Next" action="{!Next}" rerender="pgTable,pgBlock" status="status"/>
</apex:pageblockbuttons>
</apex:pageblock>
</apex:form>
</apex:page>
I want to show edit page of opportunity when edit button on list of opportunity will be clicked, after that when save is clicked again we can view the list on same block

VF page
<apex:page showHeader="true" sidebar="true" controller="SalesOrderEntryController" >
    <apex:form>
    <apex:pageBlock title="Account Detail">
            <apex:pageBlockButtons>
                <apex:commandButton value="Save" action="{!saveAcc}" reRender="editButton" />
                <apex:commandButton value="Edit" action="{!editAcc}" reRender="savebutton"/>
            </apex:pageBlockButtons >
        <apex:pageBlockSection  id ="savebutton" rendered="{!rend}" >
                <apex:inputField value="{! acc.Name }" label="Account Name" />
                <apex:inputField value="{! acc.CurrencyIsoCode }" label="Account Currency Code"/>
                <apex:inputField value="{!acc.OwnerId}" label="Owner"/>
                <apex:inputField value="{!acc.Locked_Employees__c}" label="Employess"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection  id ="editButton" >    
                <apex:outputField value="{! acc.Name }" label="Account Name"/>
                <apex:outputField value="{! acc.CurrencyIsoCode }" label="Account Currency Code"/>
                <apex:outputField value="{!acc.OwnerId}" label="Owner"/>
                <apex:outputField value="{!acc.Locked_Employees__c}" label="Employess"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock title="Related Opportunities" id="opps">
            <apex:pageblocktable value="{!listOfOpps}" var="o">
                <apex:column>
                    <apex:commandbutton value="Edit" rerender="opps" rendered="{!!( opptoBeEdited == o.Id )}">
                        <apex:param assignTo="{!opptoBeEdited}" value="{!o.Id}" name="optobeedited"/>
                    </apex:commandbutton>
                    <apex:commandButton value="Save" action="{!oppEditSaveClicked}" reRender="opps" rendered="{!opptoBeEdited == o.Id}"/>
                </apex:column>                
                <apex:column  headerValue="Opportunity Name" >
                    <apex:commandLink action="{!OppClicked}" reRender="opliDetail, orderDetail,tabp" >
                        <apex:outputField value="{!o.Name}" rendered="{!!opptoBeEdited == o.Id}"/>
                        <apex:param name="oppId" value="{!o.Id}" assignTo="{!selectedOPId}"/>
                    </apex:commandLink>
                    <apex:inputField  value="{!o.Name}"  rendered="{!(opptoBeEdited == o.Id)}"/>
                </apex:column>
            </apex:pageblocktable>
                <apex:panelGrid columns="10" style="margin-left:40%">
                    <apex:commandButton status="fetchStatus" reRender="opps" value="First" action="{!con.first}" disabled="{!!con.hasPrevious}" title="First Page"/>
                    <apex:commandButton status="fetchStatus" reRender="opps" value="Previous" action="{!con.previous}" disabled="{!!con.hasPrevious}" title="Previous Page"/>
                    <apex:commandButton status="fetchStatus" reRender="opps" value="Next" action="{!con.next}" disabled="{!!con.hasNext}" title="Next Page"/>
                    <apex:commandButton status="fetchStatus" reRender="opps" value="Last" action="{!con.last}" disabled="{!!con.hasNext}" title="Last Page"/>
                    <apex:outputText >{!(con.pageNumber * size)+1-size}-{!IF((con.pageNumber * size)>noOfRecords, noOfRecords,(con.pageNumber * size))} of {!noOfRecords}</apex:outputText>
                </apex:panelGrid>
        </apex:pageBlock>
        <apex:pageBlock>
        <apex:pageBlockSection>
            <apex:tabPanel switchType="client" selectedTab="tabopli" id="tabp" >
                <apex:tab id="tabopli" label="Opportunity Line Item" name="OPLI" >
                    <apex:pageBlockTable id="opliDetail" value="{!productFromOPLI}" var="opli" style="float:right;" title="OpportunityLineItem Details">
                        <apex:column headerValue="Product Name" value="{!opli.Product2.Name}"/>
                        <apex:column headerValue="Porduct Code" value="{!opli.Product2.ProductCode}"/>
                        <apex:column headerValue="TotalPrice" value="{!opli.TotalPrice}"/>
                        <apex:column headerValue="Quantity" value="{!opli.Quantity}"/>
                    </apex:pageBlockTable>
                </apex:tab>
                <apex:tab id="tabOrder" label="OrderItems"  name="OrderI">
                    <apex:pageBlockTable value="{!listOfOrderLI}" var="ord" id="orderDetail" title="OrderItem Details">
                        <apex:column headerValue="Order Item Number" value="{!ord.OrderItemNumber}"/>
                        <apex:column headerValue="Product Name" value="{!ord.PricebookEntry.Product2.Name}"/>
                        <apex:column headerValue="UnitPrice"  value="{!ord.UnitPrice}"/>
                        <apex:column headerValue="Quantity" value="{!ord.Quantity}"/>
                    </apex:pageBlockTable>
                </apex:tab>
            </apex:tabPanel>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Controller
public with sharing class SalesOrderEntryController {
    
    public Account acc{ get; set; }
    public List<Opportunity> listOfOpps;

    public Id opptoBeEdited{ get; set; }

    Public Integer noOfRecords{get; set;}
    Public Integer size{get;set;}

    //we take a variable of ID of selected Opportunity  property
    public Id selectedOPId{ get; set; }


    //we take a variable of List of OrdrItem property
    public List<OrderItem> listOfOrderLI{ get; set; }

    //we take a variable of Product property
    public List<OpportunityLineItem> productFromOPLI{ get; set;}

    // property for selected Order id (on which the Save is clicked - inline save)
    public String selectedOrderLIId { get; set; }

    // property for selected OppLI id (on which the Save is clicked - inline save)
    public String selectedOPLIId { get; set; }

    
    public SalesOrderEntryController() {
        this.acc = [select Id, Name,CurrencyIsoCode, OwnerId, Locked_Employees__c from Account
                            where Id = :ApexPages.currentPage().getParameters().get('id')];
        this.listOfOpps = new List<Opportunity>();
        this.listOfOrderLI = new List<OrderItem>();
        this.productFromOPLI = new List<OpportunityLineItem>();
    }

    public Pagereference saveAcc(){
        try{
            update acc;
            this.acc = [select Id, Name,CurrencyIsoCode, OwnerId, Locked_Employees__c from Account
                            where Id = : acc.Id ];
            return null;
        }catch(Exception ex){
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, ' you cannot edit this acc'+ex.getMessage());
            ApexPages.addMessage(msg);
            return null;
        }
        
    }
    public Pagereference editAcc(){
        try{
            this.acc = [select Id, Name,CurrencyIsoCode, OwnerId, Locked_Employees__c from Account
                            where Id = : acc.Id ];
            return null;
        }catch(Exception ex){
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, ' you cannot view this acc'+ex.getMessage());
            ApexPages.addMessage(msg);
            return null;
        }
        
    }




    // ApexPages.StandardSetController must be instantiated   
    //
    /*
    * pagination methods
    */
    // standard set controller      
    public ApexPages.StandardSetController con {
        get {
            size = 4;
            if(con == null) {
                con = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [ Select Id, Name, Account.Name, CloseDate, Amount, Type from Opportunity where AccountId =: acc.Id ]));
                con.setPageSize(size);
                noOfRecords = con.getResultSize();
            }
            return con;
        }
        set;
    }

     
    // Initialize setCon and return a list of records
   
    public List<Opportunity> getlistOfOpps() {
         List<Opportunity> opplist = new List<Opportunity>();
         for( Opportunity o :(List<Opportunity>)con.getRecords() )
            opplist.add(o);
         return opplist;
    }

    public void oppEditSaveClicked(){
        try{
            Opportunity tobeUpdatedOp;
            for( Opportunity tempOpp :listOfOpps ){
                if( tempOpp.Id == opptoBeEdited ){
                    tobeUpdatedOp = tempOpp;
                    break;
                }
            }
            update tobeUpdatedOp;
            tobeUpdatedOp = null;
            }catch(Exception e){
            ApexPages.Message errMess = new ApexPages.Message(ApexPages.Severity.ERROR, ' you cannot view Orderitem for this Opp'+e.getMessage());
            ApexPages.addMessage( errMess );
        }
    }
 

    public Void OppClicked(){
        try{
            this.listOfOrderLI = [ Select Id, OrderId , PricebookEntryId, CurrencyIsoCode,
                                                            UnitPrice, Quantity, OrderItemNumber,  PricebookEntry.Product2.Name
                                                            from OrderItem
                                                            where Order.OpportunityId =:selectedOPId
                                                            and  Order.AccountId =:this.acc.Id ];
            System.debug('=====opp id====' + selectedOPId);
            if( listOfOrderLI.isEmpty() ){
                ApexPages.Message noOrderItem = new ApexPages.Message(ApexPages.Severity.INFO, ' There are no OrderItem');
                ApexPages.addMessage( noOrderItem );
            }

        }catch(Exception e){
            ApexPages.Message errMess = new ApexPages.Message(ApexPages.Severity.ERROR, ' you cannot view Orderitem for this Opp'+e.getMessage());
            ApexPages.addMessage( errMess );
        }
        try{
            this.productFromOPLI = [ Select Id, Product2.Id, TotalPrice, Quantity, Product2.ProductCode, UnitPrice,
                                                                Product2.Family, Product2.Name , OpportunityId from Opportunitylineitem
                                                                where OpportunityId =:selectedOPId and Opportunity.AccountId =: this.acc.Id ];
        }catch(Exception e1){
            ApexPages.Message errMess = new ApexPages.Message(ApexPages.Severity.ERROR, ' you cannot view OpportunityLineItem for this Opp'+e1.getMessage());
            ApexPages.addMessage( errMess );
        }
    }
}

below page how can i show the edit page of that clicked opportunity with few field and save button, and when save is clicked then again list opp opportunity will be apeared.
User-added image
Module - Change Management
Topic- Deploying from Sandbox with Change Sets

Question
User-added image
and four step process is
User-added image
2.A is correct, but it wasnot written anywhere that validate inbound change set is optional,
so why 2.D is wrong?
  • Create an OData 2.0 External Data Source named 'Mobile Devices' using the following URL: https://phone-odata-demo.herokuapp.com/devices.svc/
  • Use the 'AtomPub' format and the 'Anonymous' Identity Type for the 'Mobile Devices' External Data Source.
  • The 'Mobile Devices' data source must validate and sync the 'phone_plans' table to result in an external object with the API name 'Phone_Plan__x'.
  • The 'Mobile Devices' data source must validate and sync the 'phones' table to result in an external object with the API name 'Phone__x'.
  • Note that you will need to adjust the Object Names for the two external objects from the default setting after the initial sync.
User-added image

all the thing have been done but i am getting following errorwhile checking challenge.

User-added image
In this challenge you will build a custom schema to track campsite data. In order to do this, you need to create the ability for many users to reserve many campsites. This will require a many-to-many relationship between the campsite, the users and the reservations.Create an object with 'Campsite' as the Label and Object Name. The object must have the resulting API name of 'Campsite__c'.
The Name field for Campsite must be a Text type (not Auto Number).
Add a custom field to Campsite with the type 'Text Area (Long)' with the field name and label of 'Description'. The resulting API name should be 'Description__c'. The field should have the default character length of 32,768.
Create an object with the Label 'Campsite Reservation' and Object Name of 'Campsite_Reservation'. The resulting API name should be 'Campsite_Reservation__c'.
The Name field for Campsite Reservation must be a 'Auto Number' type (not Text). Use 'CR-{0000}' as the display format for the Name field and a starting number of 1.
Add a custom field to Campsite Reservation with the type 'Lookup' related to the 'User' object with the field name and label of 'User' and Child Relationship Name of 'Campsite_Reservations'. The resulting API name should be 'User__c'.
Add a custom field to Campsite Reservation with the type 'Date' with the field label 'Start Date' and name of 'Start_Date'. The resulting API name should be 'Start_Date__c'.
Add a custom field to Campsite Reservation with the type 'Date' with the field label 'End Date' and name of 'End_Date'. The resulting API name should be 'End_Date__c'.
Add a custom field to Campsite Reservation with the type 'Master-Detail' related to the 'Campsite' object with the field name and label of 'Campsite' and Child Relationship Name of 'Campsite_Reservations'. The resulting API name should be 'Campsite__c'.


i have created required field for Campsite__c object, is there something wrong?campsite object
Hi, i want show list of opportunitylineitem when i click one opportunity from list of opp related to one account but its not working

vf Page:
<apex:page  controller="HTMLtestCon" showHeader="true" sidebar="true">
    <script type="text/javascript">
        function accountOpp(){
            var recordid = '{!$currentpage.parameters.id}';
            Visualforce.remoting.Manager.invokeAction(
                '{!$RemoteAction.HTMLtestCon.loadOpps}',
                recordid,
                function(result, event){
                    if (event.status) {
                        for (var i = 0; i < result.length; i++) {
                            var resultName = result[i].Name;
                            document.getElementById("{!$Component.block.blockSection.firstItem.OpportunityName}").innerHTML +=  resultName +'<br/>';
                            var resultAmount = result[i].Amount;
                            document.getElementById(
                                "{!$Component.block.blockSection.secondItem.amount}"
                            ).innerHTML += resultAmount +'<br/>';
                            var resultCloseDate = new Date(result[i].CloseDate);
                            document.getElementById(
                                "{!$Component.block.blockSection.thirdItem.CloseDate}"
                            ).innerHTML += resultCloseDate +'<br/>';

                        }
                    } else if (event.type === 'exception') {
                        document.getElementById("responseErrors").innerHTML =
                            event.message + "<br/>\n<pre>" + event.where + "</pre>";
                    } else {
                        document.getElementById("responseErrors").innerHTML = event.message;
                    }
                },
                {escape: true}
             );

        }
        function oppLineItems(){
            var oppName = document.getElementById('OpportunityName').value;
            Visualforce.remoting.Manager.invokeAction(
                '{!$RemoteAction.HTMLtestCon.loadOPLI}',
                recordid,
                function(result, event){
                    if (event.status) {
                        for (var i = 0; i < result.length; i++) {
                            var resultName2 = result[i].Product2.Name;
                            document.getElementById("{!$Component.block2.blockSection2.firstItem2.Product2Name}").innerHTML +=  resultName2 +'<br/>';
                            var resultQuantity = result[i].Quantity;
                            document.getElementById(
                                "{!$Component.block2.blockSection2.secondItem2.Quantity}"
                            ).innerHTML += resultQuantity +'<br/>';
                            var resultUnitPrice = new Date(result[i].UnitPrice);
                            document.getElementById(
                                "{!$Component.block2.blockSection2.thirdItem2.UnitPrice}"
                            ).innerHTML += resultUnitPrice +'<br/>';

                        }
                    } else if (event.type === 'exception') {
                        document.getElementById("responseErrors").innerHTML =
                            event.message + "<br/>\n<pre>" + event.where + "</pre>";
                    } else {
                        document.getElementById("responseErrors").innerHTML = event.message;
                    }
                },
                {escape: true}
             );
        }
    </script>

    <button onclick="accountOpp()">Related Opps</button>
    <div id="responseErrors"></div>

    <apex:pageBlock id="block">
        <apex:pageBlockSection id="blockSection" columns="3">
            <apex:pageBlockSectionItem id="firstItem">
                <apex:outputLink id="OpportunityName"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem id="secondItem">
                <apex:outputText id="amount"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem id="thirdItem">
                <apex:outputText id = "CloseDate" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
    <apex:pageBlock id="block2">
        <apex:pageBlockSection id="blockSection2" columns="3">
            <apex:pageBlockSectionItem id="firstItem2">
                <apex:outputText  id="Product2Name"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem id="secondItem2">
                <apex:outputText id="Quantity"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem id="thirdItem2">
                <apex:outputText id = "UnitPrice" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>



controller:

public class HTMLtestCon {
 
    @RemoteAction
    public static List<Opportunity> loadOpps( id recordid){
        List<Opportunity> listOfOpps = new List<Opportunity>();
        listOfOpps = [ Select Id, Name, Account.Name, CloseDate, Amount, Type from Opportunity
                                        where AccountId =: recordid ];
        return listOfOpps;
    }

    @RemoteAction
    public static List<OpportunityLineItem> loadOPLI( String oppName ){
        List<OpportunityLineItem> listofOPLI = new List<OpportunityLineItem>();
        listofOPLI = [ Select Id, Product2.Id, TotalPrice, Quantity, Product2.ProductCode, UnitPrice,
                                                                Product2.Family, Product2.Name , OpportunityId from Opportunitylineitem
                                                                where OpportunityId =:oppName ];
        return listofOPLI;
    }

}

also i want to stop opportunity list multiple time when i am clicking related opp button.


User-added imageUser-added image
how can i disable next when there is the last page or disable previous when i am on the first page

this is my controller:
public with sharing class OppOPLiOffSetPagination {

public Opportunity opp { get;set; }
public Integer pageNumberOPLI = 0 ;
public List<opportunitylineitem> listOfOpli { get; set; }
private Integer pageSizeOPLI = 5;
public String oppId{ get;set; }

public OppOPLiOffSetPagination() {
this.opp = [ Select Id, Name, Account.Name, Amount
from Opportunity
where Id = :ApexPages.currentPage().getParameters().get('id')];
this.oppId = this.opp.Id;
this.listOfOpli = new List<opportunitylineitem>();

}

public PageReference opprtunityLIneitemList(){
queryOPLI();
return null;
}

private void queryOPLI(){
Integer OffsetSize = pageNumberOPLI *pageSizeOPLI;
String opliQuery = ' Select Product2.Id, TotalPrice, Quantity, Product2.ProductCode, UnitPrice,'+
                                    'Product2.Family, Product2.Name , OpportunityId from OpportunityLineItem'+
                                    ' where OpportunityId =:oppId limit ' + pageSizeOPLI + ' offset ' + OffsetSize;
        this.listOfOpli = Database.query(opliQuery);

}

public PageReference Next() {
pageNumberOPLI++;
queryOPLI();
//enableDisablePaginationLinks();
return null;
}

public PageReference Previous() {
pageNumberOPLI--;
if (pageNumberOPLI < 0)
return null;
queryOPLI();
return null;
}

}

and here is my page:
<apex:page showheader="true" sidebar="true" controller="OppOPLiOffSetPagination">
<apex:form>
<apex:pageblock title="Opportunity Detail">
<apex:pageblocksection>
<apex:outputtext label="Name" value="{!opp.Name}"/>
<apex:outputtext label="Amount" value="{!opp.Amount}"/>
<apex:outputtext label="Account Name" value="{!opp.Account.Name}"/>
</apex:pageblocksection>
</apex:pageblock>
<apex:pageblock id="pgBlock">
<apex:pageblockbuttons>
<apex:commandbutton action="{!opprtunityLIneitemList}" value="Show Opps" rerender="pgBlock"/>
</apex:pageblockbuttons>
<apex:pageblocktable title="OPLI Detail" value="{!listOfOpli}" var="opli" id="pgTable">
<apex:column value="{!opli.Product2.Id}"/>
<apex:column value="{!opli.TotalPrice}"/>
<apex:column value="{!opli.Quantity}"/>
<apex:column value="{!opli.UnitPrice}"/>
<apex:column value="{!opli.Product2.Name}"/>
</apex:pageblocktable>
<apex:pageblockbuttons>
<apex:commandbutton value="Previous" action="{!Previous}" rerender="pgTable,pgBlock" status="status"/>
<apex:commandbutton value="Next" action="{!Next}" rerender="pgTable,pgBlock" status="status"/>
</apex:pageblockbuttons>
</apex:pageblock>
</apex:form>
</apex:page>
In this challenge you will build a custom schema to track campsite data. In order to do this, you need to create the ability for many users to reserve many campsites. This will require a many-to-many relationship between the campsite, the users and the reservations.Create an object with 'Campsite' as the Label and Object Name. The object must have the resulting API name of 'Campsite__c'.
The Name field for Campsite must be a Text type (not Auto Number).
Add a custom field to Campsite with the type 'Text Area (Long)' with the field name and label of 'Description'. The resulting API name should be 'Description__c'. The field should have the default character length of 32,768.
Create an object with the Label 'Campsite Reservation' and Object Name of 'Campsite_Reservation'. The resulting API name should be 'Campsite_Reservation__c'.
The Name field for Campsite Reservation must be a 'Auto Number' type (not Text). Use 'CR-{0000}' as the display format for the Name field and a starting number of 1.
Add a custom field to Campsite Reservation with the type 'Lookup' related to the 'User' object with the field name and label of 'User' and Child Relationship Name of 'Campsite_Reservations'. The resulting API name should be 'User__c'.
Add a custom field to Campsite Reservation with the type 'Date' with the field label 'Start Date' and name of 'Start_Date'. The resulting API name should be 'Start_Date__c'.
Add a custom field to Campsite Reservation with the type 'Date' with the field label 'End Date' and name of 'End_Date'. The resulting API name should be 'End_Date__c'.
Add a custom field to Campsite Reservation with the type 'Master-Detail' related to the 'Campsite' object with the field name and label of 'Campsite' and Child Relationship Name of 'Campsite_Reservations'. The resulting API name should be 'Campsite__c'.


i have created required field for Campsite__c object, is there something wrong?campsite object