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
Ted ChapmanTed Chapman 

Print Anything - Duplication of Merge Field Names

Greetings,
 
I am working on a Print Anything package to display shipping rate quotations. Each Quote (Opportunity) has multiple Freight Charges (custom object, child of Opportunity), and each Freight Charge has an Origin and a Destination. Origin and Destination are both joins to a custom Location object.
 
Here's the problem, I have a SOQL query in the package of the following structure:
 
select Origin__c, Origin__r.Name, Destination__c, Destination__r.Name, Minimum__c, Remarks__c, Units__c, Per_Unit__c, CurrencyIsoCode from Freight_Charge__c Where Opportunity__c = [opportunity id]
 
The query works correctly and pulls the right data, but Print Anything assigns both Origin__r.Name and Destination__r.Name to the same Merge Field value of Freight_Charge__c4.Location__c.Name.n. In the debug output of Print Anything, I can see the 2 correct Location names, but I cannot access them individually in order to print correctly.
 
 
Ron HessRon Hess
without debugging the printanything, which i'd do if i had more coffee, but i've been cut off tonnight,

i'd say break up your SOQL query into two seperate queries, one to get Origin_r.Name and then another to get Destination__r.Name, like:

select Origin__c, Origin__r.Name, Minimum__c, Remarks__c, Units__c, Per_Unit__c, CurrencyIsoCode from Freight_Charge__c Where Opportunity__c = [opportunity id]

and then another sequence (5)

select  Destination__c, Destination__r.Name, Minimum__c, Remarks__c, Units__c, Per_Unit__c, CurrencyIsoCode from Freight_Charge__c Where Opportunity__c = [opportunity id]


these would then show up as
Freight_Charge__c4.Location__c.Name.n
and
Freight_Charge__c5.Location__c.Name.n


right?
Ted ChapmanTed Chapman

Interesting thought, any idea whether or not the rows would come out in the same order? That is, would Freight_Charge__c4.Location__c.Name.n and Freight_Charge__c5.Location__c.Name.n both refer to the same record for the same value of n?

Will try to see if it works, but I'm a little afraid it will work on test case but not be structurally sound for all cases...

 

 

Thanks for the response!!!

Ted ChapmanTed Chapman
Tried the suggestion and it seems to be working! The quote printed correctly on the first test and I will try others. Any idea from the underlying technical side whether the 2 queries are gauranteed to stay in synch, so long as both Destination and Origin are required fields?
 
THANKS AGAIN!!!
Ron HessRon Hess
ok, to make the rows in both queries come out in the same order, add an order by clause to both.

order by createddate

should work, then both queries will have the same rows in the same order