2

I've got this looping ampscript retrieving rows from Salesforce object below. And I'm trying to figure out if we can retrieve them in an ordered lookup? Like a LookUpOrderRows function would work.

screen capture of looping email content attached

%%[ 
Var @RackPrice, @RackPriceRow, @BatchID__c, @Effective_Date__c, @Terminal_Number__c, @Terminal_Name__c, @Rack_Notification_Sold_To__c, @i

Set @RackPrice = RetrieveSalesforceObjects("rack_price_notification__c","Terminal_Number__c,Effective_Date__c,Terminal_Name__c,Rack_Notification_Sold_To__c","Rack_Notification_Sold_To__c", "=", @AccountId,"BatchID__c", "=", @BatchID) 

if RowCount(@RackPrice) > 0 then 
For @i=1 TO RowCount(@RackPrice) DO 
Set @RackPriceRow = Row(@RackPrice, @i) 

Set @Effective_Date__c = FIELD(@RackPriceRow,"Effective_Date__c")
Set @Terminal_Number__c = FIELD(@RackPriceRow,"Terminal_Number__c")
Set @Terminal_Name__c = FIELD(@RackPriceRow,"Terminal_Name__c")
Set @Rack_Notification_Sold_To__c = FIELD(@RackPriceRow,"Rack_Notification_Sold_To__c")
]%% 

Effective_Date__c: %%=FormatDate(@Effective_Date__c, 'mm-d-yyyy')=%%<br>
Terminal_Number__c: %%=v(@Terminal_Number__c)=%%<br>
Terminal_Name__c: %%=v(@Terminal_Name__c)=%%<br>
Rack_Notification_Sold_To__c: %%=v(@Rack_Notification_Sold_To__c)=%%
<br><br>

%%[
/* nested loop for links data retrieve */ 
NEXT @i endif ]%% 

Any ideas are appreciated. Thank you!

1 Answer 1

1

As far as I know, retrieving ordered rows from a SF Object is not possible AMPScript.

I'd probably write a SSJS Script Activity to write your SF data and store it in a Data Extension. Then you can retrieve it with a LookupOrderedRows() function in your email or landing page.

I suppose you could also mix SSJS and AMPScript and build your result-set as a JSON object and use SSJS to sort it, but that seems more heroic than the SSJS Activity.

You must log in to answer this question.

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