Skip to main content
Nintex Community Menu Bar
Question

Merge Syntax Subquery Conditions

  • July 10, 2024
  • 10 replies
  • 13 views

Forum|alt.badge.img+10

I need some guidance on subqueries. Can you use merge syntax in a subquery? I have an invoice line object connected to a Rebate Line object via the item object. I want a subquery condition that looks at the invoice date and see if it is in between the start and end date found on the rebate line. 

I get the below error:

1. An error occurred while attempting to perform the following SOQL query: SELECT SCMC__Invoicing__r.SCMC__Invoice_Date__c,SCMC__Item__c,SCMC__Item__r.Name,SCMC__Applied_Rebate_Amount__c,Id,CurrencyIsoCode FROM SCMC__Invoice_Line_Item__c WHERE (SCMC__Item__c in (SELECT SCMC__Item__c FROM SCMC__Rebate_Line__c WHERE (((SCMC__Rebate__r.SCMC__Start_Date__c >= SCMC__Invoicing__r.SCMC__Invoice_Date__c)AND(SCMC__Rebate__r.SCMC__End_Date__c <= SCMC__Invoicing__r.SCMC__Invoice_Date__c)))))AND(SCMC__Applied_Rebate_Amount__c != null) LIMIT 21 Error:expecting a colon, found ‘SCMC__Invoicing__r.SCMC__Invoice_Date__c’

This topic has been closed for replies.

10 replies

Forum|alt.badge.img+20

Hard to understand the error, but I think you could use “Field from Another Model” for the value.


Forum|alt.badge.img+10
  • Author
  • July 10, 2024

The “Field from Another Model” only looks at the first line of the model. I can get a flag created with ui-only fields to accomplish this but because I can’t use the ui-only field in a condition I can’t filter the actual data.


Forum|alt.badge.img+20

Actually, you can switch the operator from “=” to “in” and then all fieds values from all rows would be used.


Forum|alt.badge.img+10
  • Author
  • July 10, 2024

Right, but I need greater than and less than operators.


Forum|alt.badge.img+20

I see. You only want to display invoice line items where the invoice date is between the start or end dates of rebates.

I  assume these records don’t have any direct relationships?


Forum|alt.badge.img+10
  • Author
  • July 10, 2024

Exactly! You are correct there is not a direct relationship. 


Forum|alt.badge.img+20

So, by extension, you would display line items for the invoice(s) who’s date is between the start and end date of the rebates.

I’d create agg models for the rebate records for max and min. You can then use “Field from Another Model”.


Forum|alt.badge.img+10
  • Author
  • July 10, 2024

Ahh that is a very good idea. Let me give it a shot. Thanks Pat.


Forum|alt.badge.img+10
  • Author
  • July 10, 2024

Pat - I tried your suggestion but using the “Field from Another Model” for the Agg field still only looks at the first row when using greater or less than.


Forum|alt.badge.img+5

So global merge syntax in the sub-conditional logic of a conditional sub-query is not possible i take it?