-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiii_ue_customer_audit_trail.js
72 lines (65 loc) · 2.48 KB
/
iii_ue_customer_audit_trail.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/record'], function (record) {
return {
afterSubmit: function (context) {
var customer = context.newRecord;
var customerId = customer.getValue('id');
var customerEmail = customer.getValue('email');
var customerPhone = customer.getValue('phone');
var salesRepName = customer.getValue('salesrep');
var couponCode = customer.getValue('custentityiii_coupon_code');
log.audit('Sales Rep Name', salesRepName);
log.audit('Coupon Code', couponCode);
log.audit('Customer ID', customerId);
log.audit('Customer', customer);
if (context.type === context.UserEventType.CREATE) {
var customer = context.newRecord;
var customerFollowUp = record.create({
type: record.Type.TASK,
isDynamic: true,
defaultValues: {
customform: -120
}
});
customerFollowUp.setValue({
fieldId: 'priority',
value: 'HIGH'
});
customerFollowUp.setValue({
fieldId: 'title',
value: 'New Customer Follow-Up',
});
customerFollowUp.setValue({
fieldId: "company",
value: customerId
});
customerFollowUp.setValue({
fieldId: 'message',
value: 'Please take care of this customer and follow up soon.'
});
if (customer.getValue('salesrep')) {
log.audit('In conditional', 'you are in');
//customerFollowUp.setValue({
//fieldId: 'assigned',
// value: salesRepName
//});
}
try {
var customerFollowUpId = customerFollowUp.save();
log.audit({
title: 'Customer Follow Up Task record created successfully',
details: 'New task record ID' + customerFollowUpId
});
} catch (e) {
log.error({
title: e.name,
details: e.message
});
}
}
}
};
});