0

I need to use ampscript for marketing cloud in order to get field opportunity for an email or sms template :

I try with this :

    %%[
    VAR @id, @rs, @row, @value
    SET @id= AttributeValue('_subscriberkey') 
    SET @rs = RetrieveSalesforceObjects('Opportunity', 'Id, Signature_commercial__c', 'Id', '=', @VariableContainingTheRecordId)
    IF RowCount(@rs) == 1 THEN
    SET @row = Row(@rs, 1)
    SET @value = Field(@row, 'Signature_commercial__c')
    ELSE
    SET @value = 'Fallbackvalue'
    ENDIF
    ]%%

    %%=v(@value)%%

But it doesn't work, I don't have an error but %%=v(@value)%% display any value.

Can you help me?

Thanks in advance

capture ampscript

0

try this code instead of your code

 %%[
 VAR @id, @rs, @row, @value
SET @id= AttributeValue('_subscriberkey') 
 SET @con = RetrieveSalesforceObjects('Account', 'Id', 'Id', '=', @id)
 IF RowCount(@con)>0 THEN
  SET @rows = Row(@con, 1)
 SET @peid = Field(@rows, 'Id')
 endif
SET @rs = RetrieveSalesforceObjects('Opportunity', 'Id, Signature_commercial__c', 'Id', '=', @peid)
IF RowCount(@rs) == 1 THEN
SET @row = Row(@rs, 1)
SET @value = Field(@row, 'Signature_commercial__c')
ELSE
SET @value = 'Fallbackvalue'
ENDIF
]%%

%%=v(@value)=%%
|improve this answer|||||

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.