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
Wade Lovell 84Wade Lovell 84 

Why is Flow Builder trying to access CreatedDate on Territory2 and how do I stop it from doing so?

Wade Lovell 
Why is Flow Builder trying to access CreatedDate on Territory2 and how do I stop it from doing so?
I am building a Flow and while debugging on the canvas I get this error:
Debug Details
; nested exception is: common.exception.ApiQueryException: = '0052400000600n8')) ORDER BY CreatedDate ASC LIMIT 1 ^ ERROR at Row:1:Column:103 No such column 'CreatedDate' on entity 'Territory2'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

This information is absolutely correct and totally useless! (Remind anyone else of an old joke about economists?) I am not asking Flow Builder to access this non-existent field on Territory2. 

Does someone here know how to change this behavior?

Is there a tool to convert this FLOW to APEX where I can control the SOQL SELECT statement?
Do I have to start from scratch? Does someone here know how to change this behavior?

Thanks in advance,
Wade

https://trailblazer.me/id/wlovell1 
AnudeepAnudeep (Salesforce Developers) 
Hi Wade, 

As per Salesforce documentation, CreatedDate field is not available as a field for 'Territory2' object.

>> https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_territory2.htm

So this is a limitation of this object as without having CreatedDate field on the object it can't be used in Scheduled Trigger Flows in Start Element.

Scheduled Flow triggers Standard Query build up and CreatedDate field is included by default in a query. However as CreatedDate field is not supported for this object, flow is throwing an error.

I have seen a similar issue in the past and providing a workaround described there for your reference

Workaround:
===========

If you are using Get Records Element to fetch the records even if you have already had all the records for processing in the Scheduled Trigger Element.

Instead, you can remove the object reference from the Scheduled Trigger start element and use the same condition in the Get Records Element

User-added image
Let me know if this helps