Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7727069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:22:01+00:00 2026-06-01T05:22:01+00:00

I have 2 custom objects: ‘Package’ and ‘Order’. ‘Order’ includes ‘Package’ field and some

  • 0

I have 2 custom objects: ‘Package’ and ‘Order’. ‘Order’ includes ‘Package’ field and some other fields. I need to specify different field values for several ‘Order’ instances in one table. ‘Order’ object is not stored in database when rendered in table (ID = null), and its relation with ‘Package’ object is read-only. The question is how to bind all inputted data to proper ‘Order’ objects?

I have the following visualforce source. May be I should add some hidden field to specify relation between Order and paticular Package, but I don’t understant how to do it right.

<apex:pageBlockTable value="{!products}" var="product">
            <apex:column headerValue="Product Type">
                <apex:outputLink value="/{!product.Package__r.ID}">{!product.Package__r.name}</apex:outputLink>
            </apex:column>
            <apex:column value="{!product.package__r.X12NC__c}"/>
            <apex:column value="{!product.package__r.Product_Description__c}"/>
            <apex:column value="{!product.package__r.Stock__c}"/>
            <apex:column value="{!product.package__r.Expected__c}"/>
            <apex:column value="{!product.package__r.Product_Status__c}"/>                
            <apex:column value="{!product.package__r.Max_Qty__c}"/>                
            <apex:column headerValue="Quantity">                    
                <apex:inputField value="{!product.amount__c}"/>
            </apex:column>
        </apex:pageBlockTable>
        <apex:commandButton value="Make order" action="{!makeOrder}"/>

Also see fragment of my Controller:

public class OrdersController {

public String X12NC { get; set; }

public String productType { get; set; }

public List<max__Order__c> orders = new List<max__Order__c>();    

public Set<max__Order__c> ordered{ get; set; }

public Integer orderedNumber { get { return ordered.size(); } }

public OrdersController() {
    System.debug(Logginglevel.INFO, 'Start constructor');
    this.X12NC = ApexPages.currentPage().getParameters().get('x12nc');
    this.productType = ApexPages.currentPage().getParameters().get('productType');
    this.ordered = new Set<max__Order__c>();
    System.debug(Logginglevel.INFO, 'productType  = ' + this.productType);
    System.debug(Logginglevel.INFO, 'x12nc = ' + this.X12NC);
}    

public ApexPages.StandardSetController conn {
    get {            
        if (conn == null) {
            System.debug(Logginglevel.INFO, 'Creating new connection!');
            String pType = this.productType == null ? '%': '%' + this.productType + '%';
            String x12nc = this.x12nc == null ? '%': '%' + this.x12nc + '%';

            System.debug(Logginglevel.INFO, 'pType  = ' + pType);
            System.debug(Logginglevel.INFO, 'x12nc  = ' + x12nc);
            conn = new ApexPages.StandardSetController(Database.getQueryLocator([
                select name, max__X12NC__c, max__Product_Description__c, max__Expected__c, max__Stock__c, max__Product_Status__c, max__Max_Qty__c from max__Package__c 
                where max__X12NC__c like :x12nc    
                and name like :pType                
                limit 2000
            ]));
            conn.setPageSize(20);                
        }
        return conn;
    }

    set;
}

// Initialize setCon and return a list of records
public List<max__Order__c> getProducts() {
    System.debug(Logginglevel.INFO, 'getProducts() call');
    orders.clear();
    for (max__Package__c pckg: (List<max__Package__c>) conn.getRecords()) {
        max__Order__c order = new max__Order__c(max__Package__r = pckg);
        orders.add(order);
    }

    return orders;
}

public PageReference search() {
    System.debug(Logginglevel.INFO, 'Call search method!');
    this.ordered.clear();
    this.conn = null;
    return null;
}

public PageReference makeOrder() {
    System.debug(Logginglevel.INFO, 'Make order');
    for (max__Order__c order: orders) {
        System.debug(Logginglevel.INFO, 'Inspecting order = ' + order);
        if (order.amount__c != null && order.amount__c > 0) {
            System.debug(Logginglevel.INFO, 'Add ' + order + ' to shopping cart');
            System.debug(Logginglevel.INFO, 'Order package = ' + order.package__c);
            ordered.add(order);
        }
    }

    System.debug('The number of objects added in shopping cart: ' + ordered.size());
    return null;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:22:03+00:00Added an answer on June 1, 2026 at 5:22 am

    I wouldn’t go with StandardSetController when dealing with more than one type of SObject. I’d consider managing the Apex myself in my own class which combines both.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF Service which returns some custom objects to a desktop client
I have an array of custom objects. The objects includes a dictionary. Something like
I have some custom objects and dictionaries that I want to sort. I want
I have two lists of custom objects and want to update a field for
I currently have to validate custom Field Objects for my application. Simply put, each
I have several custom objects in an NSArray, I need to search through all
In a PHP program I have an array of some custom objects, and I
I need to make some custom objects in VBA that will need to reference
I have a function that I want to operate on two different custom objects.
I have an NSMutableArray of custom objects called Clip. Each clip Object has some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.