0

I am creating a cloud page and I'm new to amp script and no programming knowledge at all. I have 2 DE, is possible to call 2 DE in one cloudpage?

<table>
        <thead>
            <tr>
                <th>Time</th>
                <th>Campaign Name</th>
                <th>Campaign ID</th>
                <th>Total leads </th>
               <th>Total leads send today </th>
            </tr>
        </thead>
        <tbody>

            <tr>
 %%[
   var @rows, @rowcount, @i, @row, @latest_sendDateTime, @campaignName, @campaignId, @sendStatus, @rowCount, @totalSendCount
   set @rows = lookuprows("Prod_CampaignTracker_checking","sendStatus","Sent")
   set @rowCount = rowcount(@rows)
   if @rowCount > 0 then 
    for @i = 1 to 20 do
    set @row = Row(@rows, @i)
    set @latest_sendDateTime = field(@row, "latest_sendDateTime")
    set @campaignName = field(@row, "campaignName")
    set @campaignid = field(@row, "campaignId")
    set @totalSendCount = field(@row, "totalSendCount")
 ]%%
                <td>%%=v(@latest_sendDateTime)=%%</td>
                <td>%%=v(@campaignName)=%%</td>
                <td>%%=v(@campaignId)=%%</td> 
              <td>%%=v(@totalSendCount)=%%</td>
              </tr>
                          %%[
            next @i
            endif
            ]%%
              <br>   
        </tbody>
      <br>
    </table>
    
    
    <h2>Daily Send</h2>

    <table>
        <thead>
            <tr>
                <th>Time</th>
                <th>Campaign Name</th>
                <th>Campaign ID</th>
                <th>Total leads </th>
               <th>Total leads send today </th>
            </tr>
        </thead>
        <tbody>

            <tr>
 %%[
   var @rows, @rowcount, @i, @row, @sendDatetime, @campaignName, @campaignId, @sendStatus, @rowCount
   set @rows = lookuprows("Prod_CAMPAIGN_TRACKER_sample","sendStatus","Sent")
   set @rowCount = rowcount(@rows)
   if @rowCount > 0 then 
    for @i = 1 to 20 do
    set @row = Row(@rows, @i)
    set @sendDatetime = field(@row, "sendDatetime")
    set @campaignName = field(@row, "campaignName")
    set @campaignid = field(@row, "campaignId")
    set @sendStatus = field(@row, "sendStatus")
 ]%%
                <td>%%=v(@sendDatetime)=%%</td>
                <td>%%=v(@campaignName)=%%</td>
                <td>%%=v(@campaignId)=%%</td> 
              <td>%%=v(@totalSendCount)=%%</td>
              </tr>
                          %%[
            next @i
            endif
            ]%%
              <br>   
        </tbody>
      <br>
    </table>

Error Message: "Invalid index (parameter 2) passed to Row function. Index must be less than or equal to the row count. Index Value: 20 Row Count: 19 Function: Row(@rows, @i)"

Description: "ExactTarget.OMM.FunctionExecutionException: Invalid index (parameter 2) passed to Row function. Index must be less than or equal to the row count. Index Value: 20 Row Count: 19 Function: Row(@rows, @i) Error Code: OMM_FUNC_EXEC_ERROR - from Jint "

1 Answer 1

0

For your first query you can use multiple lookuprows in one cloud pages. The reason you are getting the error because you are trying to access a row index in your lookup result that exceeds the actual number of rows returned. You can refer the below document

Ampscript error: Invalid index (parameter 2) passed to Row function. Index must be less than or equal to the row count

The loop in your code always runs for 1 to 20, but if there are fewer than 20 rows in the result set, you'll get an "Invalid index" error

You code should look like this:

<table>
    <thead>
        <tr>
            <th>Time</th>
            <th>Campaign Name</th>
            <th>Campaign ID</th>
            <th>Total leads</th>
            <th>Total leads sent today</th>
        </tr>
    </thead>
    <tbody>
        %%[
        var @rows, @i, @row, @latest_sendDateTime, @campaignName, @campaignId, @rowCount, @totalSendCount
        set @rows = lookuprows("Prod_CampaignTracker_checking","sendStatus","Sent")
        set @rowCount = rowcount(@rows)
        if @rowCount > 0 then 
            for @i = 1 to @rowCount do
                set @row = Row(@rows, @i)
                set @latest_sendDateTime = field(@row, "latest_sendDateTime")
                set @campaignName = field(@row, "campaignName")
                set @campaignid = field(@row, "campaignId")
                set @totalSendCount = field(@row, "totalSendCount")
        ]%%
        <tr>
            <td>%%=v(@latest_sendDateTime)=%%</td>
            <td>%%=v(@campaignName)=%%</td>
            <td>%%=v(@campaignId)=%%</td>
            <td>%%=v(@totalSendCount)=%%</td>
        </tr>
        %%[
            next @i
        endif
        ]%%
    </tbody>
</table>

<h2>Daily Send</h2>

<table>
    <thead>
        <tr>
            <th>Time</th>
            <th>Campaign Name</th>
            <th>Campaign ID</th>
            <th>Total leads</th>
            <th>Total leads sent today</th>
        </tr>
    </thead>
    <tbody>
        %%[
        var @rows, @i, @row, @sendDatetime, @campaignName, @campaignId, @rowCount
        set @rows = lookuprows("Prod_CAMPAIGN_TRACKER_sample","sendStatus","Sent")
        set @rowCount = rowcount(@rows)
        if @rowCount > 0 then 
            for @i = 1 to @rowCount do
                set @row = Row(@rows, @i)
                set @sendDatetime = field(@row, "sendDatetime")
                set @campaignName = field(@row, "campaignName")
                set @campaignid = field(@row, "campaignId")
                /* Note: Add @totalSendCount if it's available in this data extension */
        ]%%
        <tr>
            <td>%%=v(@sendDatetime)=%%</td>
            <td>%%=v(@campaignName)=%%</td>
            <td>%%=v(@campaignId)=%%</td>
            <!-- Ensure @totalSendCount is available, otherwise remove this column -->
            <td>%%=v(@totalSendCount)=%%</td>
        </tr>
        %%[
            next @i
        endif
        ]%%
    </tbody>
</table>
1
  • Thank you, This works,
    – yajirobi
    Commented Sep 17 at 1:17

You must log in to answer this question.

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