Anyone got a code snippet for an IF statement that...
# suitescript
d
Anyone got a code snippet for an IF statement that I can use to select a PDF template depending on subsidiary, please? Pseudo is basically IF subsidiaryid = 101 { template for this sub} elseif subsidiaryid= 102 {template for this sub} etc etc thanks
m
I tend to use object maps for this
Copy code
// Map subsidiary id to email template id
var emailTemplates = {
    1: 101,
    2: 102,
    3: 103
};

var subsidiaryId = record.getValue({ fieldId: 'subsidiary' });

// Get the template for this subsidiary, default to 105 if no template is specified.
var templateId = emailTemplates[subsidiaryId] || 105;