Skip to content
Snippets Groups Projects
Commit 0deddfc3 authored by S.Listl's avatar S.Listl
Browse files

SerialLetterAddRecipients didn't work

parent 39788b31
No related branches found
No related tags found
No related merge requests found
......@@ -8,14 +8,14 @@ import("Sql_lib");
import("system.vars");
var contactIds = JSON.parse(vars.getString("$param.ContactIds_param"));
var letterId = vars.get("$field.SERIALLETTER_ID");
var existsQuery = "not exists(select LETTERRECIPIENTID from LETTERRECIPIENT where LETTERRECIPIENT.CONTACT_ID = CONTACT.CONTACTID and # = ?)";
contactIds = newSelect("CONTACTID")
.from("CONTACT")
.and("CONTACT.CONTACTID", contactIds, SqlBuilder.IN())
.and("LETTERRECIPIENT.SERIALLETTER_ID", letterId, existsQuery) //only add contacts that aren't already recipients
.where("CONTACT.CONTACTID", contactIds, SqlBuilder.IN())
.and(null, newSelect("LETTERRECIPIENTID")
.from("LETTERRECIPIENT")
.where("LETTERRECIPIENT.CONTACT_ID = CONTACT.CONTACTID")
.and("LETTERRECIPIENT.SERIALLETTER_ID", "$field.SERIALLETTER_ID"), SqlBuilder.NOT_EXISTS()) //only add contacts that aren't already recipients
.and(ContactUtils.getCommRestrictionCondition($KeywordRegistry.communicationMediumCampaign$letter(), true)) //check if there's a commrestriction
.array(db.COLUMN)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment