I wrote the following script to pull in a Sales reps name.

var @Territory, @mdmidKey, @SalesRep
set @mdmidKey = [mdmid]
set @Territory = Lookup("BR_Call","Territory_vod__c","External_Id_vod__c",@mdmidKey)
set @SalesRep = Lookup("TerritoryVOD","SalesRep","Territory__vod__c",@Territory)

IF Empty(@SalesRep) THEN
  SET @SalesRep = "Company X"


The issue I am running into is that this work perfectly fine when I have it in an email and I am previewing my subscribers. When I put the script into my Sender Name for my dynamic sender profile, I get an error message:

"TEST SalesRep Dynamic Sender External Key: xxxx Invalid Sender Profile state. ClientID: xxxxxxx SenderProfileID: 80fb3486-712a-fb11-a2f2-1422eg948a8d Sender Profile Name: TEST SalesRep Dynamic Sender CustomerKey: xxxx The FromName AMPScript contains the following errorsScript SET Statement Invalid - "set @mdmidKey = [mdmid]""

It seems it does not like my set @mdmidKey = [mdmid] line. Is there a different way to have this formatted to work for a dynamic sender profile for the sender name?

1 Answer 1


I have worked this way:

Create a CodeSnippet Block. Give it a Customer_Key. Let's say its "GLOBAL_SENDPROFILE_FROMNAME".

Write all logic in that Codesnippet block via Ampscript. When you are sending each and every dataextension used for sending needs to have a column named mdmid, otherwise your calls most likely will return nothing. And this value always needs to be filled.

Go to your sender profile (the @SalesRep variable needs to be inside your codesnippet block) and insert this.

%%=ContentBlockbyKey("GLOBAL_SENDPROFILE_FROMNAME")=%% %%=v(@SalesRep)=%%

Also be aware of the fact what happens if your code that sets the variable @territory will not receive any records.

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.