michoel
07/27/2017, 12:18 AMvar ContactRoles = {
PRIMARY_CONTACT: -10,
ALTERNATE_CONTACT: -20,
DECISION_MAKER: -30,
CONSULTANT: -40
};
var primaryContact = record.create({ type: record.Type.CONTACT });
primaryContact.setValue({ fieldId: 'firstname', value: firstName });
primaryContact.setValue({ fieldId: 'lastname', value: lastName });
primaryContact.setValue({ fieldId: 'title', value: title });
primaryContact.setValue({ fieldId: 'email', value: email });
primaryContact.setValue({ fieldId: 'phone', value: phone });
primaryContact.setValue({ fieldId: 'company', value: company });
var primaryContactId = primaryContact.save();
record.attach({
record: { type: record.Type.CONTACT, id: primaryContactId },
to: { type: type, id: entityId },
attributes: { role: ContactRoles.PRIMARY_CONTACT }
});