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
Bruce Zheng 4Bruce Zheng 4 

Is there a way to get number of records in a Data Extension using API?

Is there a way to get number of records in a Salesforce Marketing Cloud Data Extension using API?
Best Answer chosen by Bruce Zheng 4
NagendraNagendra (Salesforce Developers) 
Hi Bruce,

Please find the solution below posted on stack exchange community with a similar discussion.

No need to use the official API. Since there's an AMPscript function that returns this data, you could build a simple Cloud Page in your account that returns a JSON payload with this information:
%%[ var @key, @rowCount set @key = QueryParameter("key") set @rowCount = iif(empty(@key), 0, DataExtensionRowCount(@key)) ]%%{ "rowCount": "%%=v(@rowCount)=%%"}
Working example: Reference:

DataExtensionRowCount Kindly mark this as solved if it's resolved.

Thanks,
Nagendra

All Answers

NagendraNagendra (Salesforce Developers) 
Hi Bruce,

Please find the solution below posted on stack exchange community with a similar discussion.

No need to use the official API. Since there's an AMPscript function that returns this data, you could build a simple Cloud Page in your account that returns a JSON payload with this information:
%%[ var @key, @rowCount set @key = QueryParameter("key") set @rowCount = iif(empty(@key), 0, DataExtensionRowCount(@key)) ]%%{ "rowCount": "%%=v(@rowCount)=%%"}
Working example: Reference:

DataExtensionRowCount Kindly mark this as solved if it's resolved.

Thanks,
Nagendra
This was selected as the best answer
Bruce Zheng 4Bruce Zheng 4
HI Nagendra, thank you so much. this solution works well for us, im marking this answer as best answer already.