• Anthony Haller
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hello,
I can do the following with apex code but I wanted to inquire if there was a way to do it without using formula creators.  I am working on a pair of custom objects (a parent and a child) and I want to apply a sequence field to control the order in which the child object's records would appear in when their parent record was selected.  Creating the field was easy but making it user friendly to create new child records for the parent has proven difficult. 

When a new record is created I originally wanted the sequence field to be default populated by a number that was the highest in the sequence of the parent record's child lots (i.e. if child record sequences 2, 4, and 6 already existed I wanted to the default value to be something like '=MAX(Parent__r.Children__r.Sequence__c) + 2' to and b populated by an 8... and yes I realize that the function syntax I just gave is bogus) .

Not able to find good documentation online for if this was possible to assign as a default value I turned to the Process Builder to have it assigned when a new child record was created via a workflow if the child sequence field was left blank during its creation.  However, once again I could not find good documentation to rule out whether or not I could do this without an Apex Class as I muddled through the process. When I search for Max or Maximum I tend to get posts about the governing limits.

Does anyone know if this might be possible in the formula creator without writing Apex code?  Thanks in advance.

Anthony
Hello,
I see plenty of threads asking how to sub query a sub query (short answer, presently you can't with the exception of using a second query after an IN statement to filter records).  I would like to know if there is a way to only subquery down one level but do it on a parent object in a query.

For example:
There are four custom objects: ProductConfig, Product, OrderList and Order.  'ProductConfig' contains multiple configurations of each product in the parent object 'Product' and 'OrderList' contains all items included in an order from the 'Order' parent object.  In other words Product is parent to ProductConfig and OrderList, and Order is parent to OrderList.

We don't care about the Order object because we cannot drill down more than one sub query.  So instead we start at the OrderList object.  If I were to write it out in SOQL it might look like:

String orderID = 'ORDER-0001';
List<OrderList__c> testOrder1 = [SELECT Product__r.Name, (SELECT Name FROM Product__r.ProductConfig__c) FROM OrderList__c WHERE Order__r.Name := orderID];

By the way, this SOQL generates the error 'First SObject of a nested query must be a child of its outer query'. 

I can work around this limitation using two queries and Apex code to place the data together, but when trying to keep Apex processing and the number of SOQL transations down to a minimum it seems like this sort of relationship join should be possible.

Any suggestions?  Thanks.
 
Hello,
I can do the following with apex code but I wanted to inquire if there was a way to do it without using formula creators.  I am working on a pair of custom objects (a parent and a child) and I want to apply a sequence field to control the order in which the child object's records would appear in when their parent record was selected.  Creating the field was easy but making it user friendly to create new child records for the parent has proven difficult. 

When a new record is created I originally wanted the sequence field to be default populated by a number that was the highest in the sequence of the parent record's child lots (i.e. if child record sequences 2, 4, and 6 already existed I wanted to the default value to be something like '=MAX(Parent__r.Children__r.Sequence__c) + 2' to and b populated by an 8... and yes I realize that the function syntax I just gave is bogus) .

Not able to find good documentation online for if this was possible to assign as a default value I turned to the Process Builder to have it assigned when a new child record was created via a workflow if the child sequence field was left blank during its creation.  However, once again I could not find good documentation to rule out whether or not I could do this without an Apex Class as I muddled through the process. When I search for Max or Maximum I tend to get posts about the governing limits.

Does anyone know if this might be possible in the formula creator without writing Apex code?  Thanks in advance.

Anthony
Hello,
I see plenty of threads asking how to sub query a sub query (short answer, presently you can't with the exception of using a second query after an IN statement to filter records).  I would like to know if there is a way to only subquery down one level but do it on a parent object in a query.

For example:
There are four custom objects: ProductConfig, Product, OrderList and Order.  'ProductConfig' contains multiple configurations of each product in the parent object 'Product' and 'OrderList' contains all items included in an order from the 'Order' parent object.  In other words Product is parent to ProductConfig and OrderList, and Order is parent to OrderList.

We don't care about the Order object because we cannot drill down more than one sub query.  So instead we start at the OrderList object.  If I were to write it out in SOQL it might look like:

String orderID = 'ORDER-0001';
List<OrderList__c> testOrder1 = [SELECT Product__r.Name, (SELECT Name FROM Product__r.ProductConfig__c) FROM OrderList__c WHERE Order__r.Name := orderID];

By the way, this SOQL generates the error 'First SObject of a nested query must be a child of its outer query'. 

I can work around this limitation using two queries and Apex code to place the data together, but when trying to keep Apex processing and the number of SOQL transations down to a minimum it seems like this sort of relationship join should be possible.

Any suggestions?  Thanks.