I'm having an issue, i can execute AMPscript within SSJS by placing my ampscript code within a Content Block and then using SSJS to execute it by using:

<script runat="server">
    Platform.Load("core", "1");
    var ampscript = Platform.Function.ContentBlockByID("XXXXXX");

Now this all works fine, the issue i have is the script failing in the automation because of the ampscript I'm using which is:


var @rows, @row, @rowCount, @counter, @Account_ID, @Equipment_Type

set @rows = DataExtensionRowCount("Accounts_with_Equipment_TEST")
set @rowCount = rowcount(@rows) 

if @rowCount > 0 then 

for @counter = 1 to @rowCount do 
set @row = row(@rows, @counter)
set @Account_ID = field(@row,"Account_ID")
set @Equipment_Type = field(@row,"Equipment_Type")

if @Equipment_Type == 'a' OR @Equipment_Type == 'b' THEN
set @result = UpdateSingleSalesforceObject('Account',@Account_ID,'AC_Soft__c','0')
@Equipment_Type == 'c' THEN
set @result = UpdateSingleSalesforceObject('Account',@Account_ID,'AC_Chilled__c','0')



I've tried removing pieces of code at a time and re-trying to find and pinpoint where the issue is. It looks like its to do with the below as it fails when there just the below ampscript:

var @rows, @rowCount

set @rows = DataExtensionRowCount("Accounts_with_Equipment_TEST")
set @rowCount = rowcount(@rows)

What am i doing wrong here? The DE is correct, I'm using INT to test this.

Any help would be much appreciated and thank you in advance.

1 Answer 1


In short: the DataExtensionRowCount() function returns a number and you are trying to pass this number to the RowCount() function which fails, because this function expects a set of rows (like it is provided by row lookup and RetrieveSalesforceObjects() functions).

If you would wrap your code in a SSJ try catch block, this error would be returned:

--- inner exception 1---

ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to evaluate a RowCount function call. See inner exception for details.
- from OMMCommon -->

--- inner exception 2---

System.ArgumentException: The type of the RowSet parameter (parameter 1) is not supported by the RowCount function.
RowSet type: Int64
Function: rowcount(@rows) - from OMMCommon

Seeing your code, it seems that the use of DataExtensionRowCount is wrong - you don't need to know how many records are there in the data extension, you need a set of data for a given account.

What you're looking for is one of those functions:

  • LookupOrderedRows
  • LookupOrderedRowsCS
  • LookupRows
  • LookupRowsCS

They will return a row set, you can process further.

  • Thank you for pointing out my error, i have now fixed this. Thank you again! Jul 29 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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