As part of an automated email we have, I made an SSJS script block to update an Email Send Definition (User-Initiated) to target a new data extension. However when we do this, it resets the publication list to 'All Subscribers' instead of the specific one we had. First there's a script which retrieves the name of the new DE (@jobno) then this runs:
<script runat=server>
Platform.Load("Core","1");
var deName = Variable.GetValue("@jobno");
var esd = Send.Definition.Init('OurEmail');
var status = esd.Update({ "DataExtensionKey" : (deName), "PubListKey" : "SpecificPubList" });
</script>
The script successfully updates the data extension, but not the publication list. I am pretty sure PubListKey is the correct parameter because changing it to PublicationListKey or anything else causes the script to error, but when I check the send definition it has updated the data extension but not the publication list.
I suspect this is because the Name of the publication list is not the same as the customer key of it - but there's no way of seeing what this is. I tried using the numeric ID too, but that also didn't work. Does anyone have any pointers?