Is there any way of doing something like,

<script runat=server>
    Platform.Load("core","1");
    //initialize DE
    var _Sent = DataExtension.Init("_Sent");
    //retrieve data
    var _Sent_data = _Sent.Rows.Retrieve();
    Write("Length: " + _Sent_data.length); //returns 0
</script>

What would the external key for a system dataview be?

The only possible way I know of to do this is via the SOAP API. But I would never use this to retrieve all the _Sent Dataview as it will time out without a doubt. Most Sent Dataviews contain a minimum of millions of records (6 months worth of sends) which is too much for any landing page or script activity to parse through.

So, judging from your question it looks like you are just looking for the size (length) of the _Sent object which can be obtainable, just through a different means.

  1. I would create a DE that contains all the _Sent Dataview fields
  2. Then create a SQL query to fill this DE with all the info from the Dataview
  3. Then you can use DataExtensionRowCount() in AMPScript to retrieve the rowcount of that DE.

Sample of Query:

SELECT *
FROM _Sent

Sample of AMPScript:

%%[ SET @SentCount = DataExtensionRowCount("mySentDataViewDE") ]%%

You can then put that query in an automation and schedule it to run at a timeframe you need it to and keep it as up to date as necessary.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.