1

I have some ampscript code to read from a data extension and populate the email template. When I go to preview I get this error.

"Invalid value specified for function parameter. Function Name: row Parameter Name: Index Parameter Ordinal: 2 Parameter Type: Numeric Submitted Value: ClientID: 7000859 JobID: 0 ListID: 0 BatchID: 0 SubcriberID: 116194632 Data Source Type: CustomObject Data Source ID: c609a413-3ee5-e911-a2d8-1402ec94b791"

I checked a previous post about naming the field parameter differently but that didnt help. If anyone has any ideas as to why this may be triggering the error that would be greatly appreciated.

%%[

Set @Rowcount = Rowcount(LookupOrderedRows("Consult_Notifications_Daily_followedreply",3,"date desc","EmailAddress",emailaddr))

IF @rows > 0 then
set @rows = LookupOrderedRows("Consult_Notifications_Daily_followedreply",3,"date desc","EmailAddress",emailaddr)

SET @RowTarget = Row(@rows,1)
    set @followedReplyPostName = field(@RowTarget,"PostName_1")
    set @followedReplyTargetURL = field(@RowTarget,"targeturl_1")
    set @followedReplyRecipientName = field(@RowTarget,"RecipientName")

    set @followedReplyUser = field(@RowTarget,"User_1")
    set @followedReplyPostTitle = field(@RowTarget,"PostTitle_1")
    set @followedReplyUserAccountUrl = field(@RowTarget,"UserAccountUrl")
    set @followedReplyActorAccountUrl = field(@RowTarget,"ActorAccountUrl_1")
    set @followedReplyThreadUrl = field(@RowTarget,"ThreadUrl_1")
    set @followedReplyDate = field(@RowTarget,"Date")
    set @followedReplyPostBody = field(@RowTarget,"PostBody_1")
    set @followedReplyMentionedUser = field(@RowTarget,"MENTIONEDUSER")




    set @followedReplyNotificationType = field(@RowTarget,"NotificationType")
    set @followedReplyActorName = field(@RowTarget,"ActorNameDeg")



]%%
--><!--
%%[

IF not empty(@PostName_1) then ]%%
  %%[ELSE]%%
%%[ENDIF]%%

-->

        <tr>
          <td style="padding: 7px 0 0 0;">
            <table width="560" cellpadding="0" cellspacing="0" borde="0" class="container">
              <tr>
                <td align="center" valign="middle" style="padding:2px 2px 3px 1px; box-shadow: 2px 2px 2px 0 rgba(0, 0, 0, 0.09);" bgcolor="#dfdfdf">
                  <table width="558" class="container" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
                    <tr>
                      <td style="padding:20px 20px 20px 20px; font-size: 14px;" align="left">
                        <table width="508" class="container" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
                          <tr>
                            <td width="508" style="padding: 0 0px 0 0;" class="container" colspan="1" valign="top">
                              <table width="508" class="container" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td align="left" style="font-size: 18px;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal;">
                                    <a href="%%=redirectTo(@followedReplyTargetURL)=%%" style="font-size: 18px;color: #000000;text-decoration:none;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal;">%%=v(@followedReplyPostName)=%%</a>
                                  </td>
                                </tr>
                                %%[if not empty(@followedReplyPostBody) then]%%
                                <tr>
                                  <td align="left" style="font-size: 14px;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal; color: #606060;">
                                    %%=v(@followedReplyPostBody)=%% .. 
                                    <a href="%%=redirectTo(@followedReplyTargetURL)=%%" target="_blank" style="font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">read more</a>
                                  </td>
                                </tr>
                                %%[endif]%%
                                <tr>
                                  <td align="left" style="padding: 0px 0 0px 0; font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; color: #3a3b3c;">
                                    <a href="%%=redirectTo(@followedReplyActorAccountUrl)=%%" target="_blank" style="font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">%%=v(@followedReplyRecipientName)=%%</a> responded to your post on %%=v(@followedReplyDate)=%%.
                                  </td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <!--%%[endif]%% -->
                <!-- End script

-->


        <!--
%%[

IF not empty(@postname2) then

]%%

-->

        <tr>
          <td style="padding: 7px 0 0 0;">
            <table width="560" cellpadding="0" cellspacing="0" borde="0" class="container">
              <tr>
                <td align="center" valign="middle" style="padding:2px 2px 3px 1px; box-shadow: 2px 2px 2px 0 rgba(0, 0, 0, 0.09);" bgcolor="#dfdfdf">
                  <table width="558" class="container" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
                    <tr>
                      <td style="padding:20px 20px 20px 20px; font-size: 14px;" align="left">
                        <table width="508" class="container" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
                          <tr>
                            <td width="508" style="padding: 0 0px 0 0;" class="container" colspan="1" valign="top">
                              <table width="508" class="container" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td align="left" style="font-size: 18px;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal;">
                                    <a href="%%=redirectTo(@followedReplyTargetURL)=%%" style="font-size: 18px;color: #000000;text-decoration:none;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal;">%%=v(@followedReplyPostName)=%%</a>
                                  </td>
                                </tr>
                                %%[if not empty(@followedReplyPostBody) then]%%
                                <tr>
                                  <td align="left" style="font-size: 14px;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal; color: #606060;">
                                    %%=v(@followedReplyPostBody)=%% .. 
                                    <a href="%%=redirectTo(@followedReplyTargetURL)=%%" target="_blank" style="font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">read more</a>
                                  </td>
                                </tr>
                                %%[endif]%%
                                <tr>
                                  <td align="left" style="padding: 0px 0 0px 0; font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; color: #3a3b3c;">
                                    <a href="%%=redirectTo(@followedReplyActorAccountUrl)=%%" target="_blank" style="font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">%%=v(@followedReplyRecipientName)=%%</a> responded to your post on %%=v(@followedReplyDate)=%%.
                                  </td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <!--%%[endif]%% -->
                <!-- End script

-->
        <!-- End Content -->
        <tr>
          <td align="center" class="mobile-pad-top-20" style="padding: 22px 0 0 0; font-size: 16px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: none; color: #3a3b3c; line-height: normal;">
            <a href="%%=redirectTo(@followedReplyUserAccountUrl)=%%" target="_blank" style="font-size: 16px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">
              See all your posts
            </a>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<!-- -->
<!-- -->
<!--END -->
1
  • 2
    The issue is you are trying to pull a row of 1 from a rowset with 0 rows. Likely need to change IF @rows > 0 to IF @Rowcount > 0 and condition should work as expected Commented Jan 19, 2020 at 0:09

1 Answer 1

2

Under the assumption that this resolved the issue, I am changing this from a comment to an answer for easier reference to anyone else experiencing this issue:

The issue is you are trying to pull a row of 1 from a rowset with 0 rows. Likely need to change IF @rows > 0 to IF @Rowcount > 0 and condition should work as expected.

See below sample:

%%[

Set @rows = LookupOrderedRows("Consult_Notifications_Daily_followedreply",1,"date desc","EmailAddress",emailaddr)
set @Rowcount = Rowcount(@rows)

IF @Rowcount > 0 then

    SET @RowTarget = Row(@rows,1)
    set @followedReplyPostName = field(@RowTarget,"PostName_1")
    set @followedReplyTargetURL = field(@RowTarget,"targeturl_1")
    set @followedReplyRecipientName = field(@RowTarget,"RecipientName")

    set @followedReplyUser = field(@RowTarget,"User_1")
    set @followedReplyPostTitle = field(@RowTarget,"PostTitle_1")
    set @followedReplyUserAccountUrl = field(@RowTarget,"UserAccountUrl")

....

You will notice, I moved rows from under the conditional and put it at the top. I then used rowcount on the rows var - this removes the need to do the lookup twice, reducing processing required and increasing efficiency.

I also changed the lookup to only grab a single row as your below code would not utilize any row beyond that, so there is no reason to have the lookup try to gather anything beyond a single row (provides slight increase in efficiency).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .