Our requirement is to capture campaign information during send time through Ampscript. ask is to capture data extension name, jobid and publication list for every campaign(unique DE-Jobid pair). I am able to populate DE with details, however we see duplicate records with same DE-Jobid pair. find the snippet below
SET @Job_Id = jobid
SET @DE = _DataSourceName
SET @Publication_List = AttributeValue("_listname")
SET @Campaign_Name = emailName_
set @date = NOW()
set @campaign_found = LookupRows("Campaign_Details_CDT","Job_ID", @Job_Id,"Segment_Name", @DE)
set @rowcount = rowcount(@campaign_found)
IF(@rowcount == 0) THEN
InsertDE("Campaign_Details_CDT", "Job_ID", @Job_Id, "Campaign_Name", @Campaign_Name, "Segment_Name", @DE, "Sent_Date", @date, "Publication_List", @Publication_List)
ENDIF
]%%````
I will appreciate your help to find reason for this.