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");
Write(TreatAsContent(ampscript));
</script>
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')
elseif
@Equipment_Type == 'c' THEN
set @result = UpdateSingleSalesforceObject('Account',@Account_ID,'AC_Chilled__c','0')
else
endif
next
else
endif
]%%
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.