@inizioevoke/veeva-astroclm 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +10 -0
- package/.claude/skills/evoke-analytics-auditor/SKILL.md +509 -0
- package/.claude/skills/evoke-astro-core/SKILL.md +395 -0
- package/.claude/skills/evoke-page-manager/SKILL.md +75 -0
- package/.claude/skills/evoke-veeva-config-manager/SKILL.md +17 -0
- package/.claude/skills/evoke-veeva-config-manager/create.md +189 -0
- package/.claude/skills/evoke-veeva-config-manager/manage.md +48 -0
- package/.editorconfig +12 -0
- package/.env.development +3 -0
- package/.env.veeva-client +1 -0
- package/.env.veeva-client-training +2 -0
- package/.env.veeva-evoke +4 -0
- package/README.md +43 -0
- package/_contents.yml.example +6 -0
- package/astro.config.ts +36 -0
- package/package.json +40 -0
- package/public/astroclm.png +0 -0
- package/public/favicon.png +0 -0
- package/public/shared/salesforce.js +2586 -0
- package/public/shared/vault.js +2417 -0
- package/src/components/content/readme.md +1 -0
- package/src/components/isi/ISIContent.tsx +137 -0
- package/src/components/isi/_isi.scss +22 -0
- package/src/components/nav/MainNav/MainNav.astro +20 -0
- package/src/components/nav/MainNav/MainNav.tsx +36 -0
- package/src/components/nav/NavList.tsx +66 -0
- package/src/components/ui/Button.astro +19 -0
- package/src/components/ui/Image.astro +36 -0
- package/src/components/ui/IvaConsole/IvaConsole.astro +12 -0
- package/src/components/ui/IvaConsole/IvaConsole.scss +62 -0
- package/src/components/ui/IvaConsole/IvaConsole.ts +144 -0
- package/src/components/ui/Link.astro +39 -0
- package/src/components/ui/Link.tsx +36 -0
- package/src/components/ui/NavLink.astro +46 -0
- package/src/components/ui/NavLink.tsx +41 -0
- package/src/components/ui/VeevaControls/VeevaControls.astro +48 -0
- package/src/components/ui/VeevaControls/VeevaControls.scss +145 -0
- package/src/components/ui/VeevaLink.astro +36 -0
- package/src/data/pages.tsx +50 -0
- package/src/env.d.ts +14 -0
- package/src/lib/client/context.ts +45 -0
- package/src/lib/client/main.ts +54 -0
- package/src/lib/client/readme.md +1 -0
- package/src/lib/client/swipe-nav.ts +35 -0
- package/src/lib/client/utils.ts +58 -0
- package/src/lib/server/readme.md +1 -0
- package/src/lib/server/screen.ts +10 -0
- package/src/middleware.ts.bak +12 -0
- package/src/scss/_mixins.scss +1 -0
- package/src/scss/_variables.scss +6 -0
- package/src/scss/ipads.scss +89 -0
- package/src/shared/img/veeva/veeva-action.png +0 -0
- package/src/shared/img/veeva/veeva-desktop-action.png +0 -0
- package/src/shared/img/veeva/veeva-desktop-navigation.png +0 -0
- package/src/shared/img/veeva/veeva-desktop-next.png +0 -0
- package/src/shared/img/veeva/veeva-desktop-previous.png +0 -0
- package/src/shared/img/veeva/veeva-highlighter.png +0 -0
- package/src/shared/img/veeva/veeva-history-back.png +0 -0
- package/src/shared/img/veeva/veeva-history-forward.png +0 -0
- package/src/shared/img/veeva/veeva-navigation.png +0 -0
- package/src/shared/img/veeva/veeva-reactions.png +0 -0
- package/tasks/page-manager.ts +4 -0
- package/tasks/util.ts +7 -0
- package/tasks/veeva-config.ts +4 -0
- package/tasks/veeva-deploy.ts +21 -0
- package/tsconfig.json +23 -0
- package/veeva-metadata.js +461 -0
|
@@ -0,0 +1,2586 @@
|
|
|
1
|
+
// Veeva JavaScript Library version 242.0.200
|
|
2
|
+
// http://veeva.com
|
|
3
|
+
//
|
|
4
|
+
// Copyright © 2024 Veeva Systems, Inc. All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
// The com.veeva.clm namespace should be utilized when calling the JavaScript functions.
|
|
7
|
+
// Example: "com.veeva.clm.getDataForCurrentObject("Account","ID", myAccountID);"
|
|
8
|
+
//
|
|
9
|
+
//
|
|
10
|
+
// JavaScript library will return in the following format:
|
|
11
|
+
// {success:true, obj_name:[{"Id":"0001929312"}, {record2}, ...]}
|
|
12
|
+
// or
|
|
13
|
+
// {success:false, code:####, message:"message_text"}
|
|
14
|
+
// #### - denotes the specific error code (1000 is from the underlying API, 2000 is from the JavaScript library)
|
|
15
|
+
// 2000 - Callback function is missing
|
|
16
|
+
// 2001 - Callback is not a JavaScript function
|
|
17
|
+
// 2002 - <parameter_name> is empty
|
|
18
|
+
// 2100 - Request (%@) failed: %@
|
|
19
|
+
// message_text - begins with the JavaScript library function name and a ":". If the error comes from the underlying API, the full message
|
|
20
|
+
// from the API will be appended to the message_text
|
|
21
|
+
//
|
|
22
|
+
//
|
|
23
|
+
// For CLM:
|
|
24
|
+
// With the exception of gotoSlide, the JavaScript functions respect My Setup, Restricted Products on Account, Allowed Products on Call and on TSF.
|
|
25
|
+
// goToSlide respects all of the above when media is launched from a Call or an Account. goToSlide does not respect Restricted Products
|
|
26
|
+
// and Allowed Products when media is launched from the home page.
|
|
27
|
+
//
|
|
28
|
+
//
|
|
29
|
+
// Use the JavaScript functions in a chain, i.e. call the second JavaScript function only in the first function's callback function or
|
|
30
|
+
// after the callback of the first function is finished.
|
|
31
|
+
// Because the underlying API calls are asynchronous, this may result in unexpected return values if the JavaScript functions are
|
|
32
|
+
// not properly chained.
|
|
33
|
+
//
|
|
34
|
+
//
|
|
35
|
+
// Veeva recommends caution when retrieving/saving data using the following field types and to always perform rigorous testing:
|
|
36
|
+
// Long Text Area
|
|
37
|
+
// Rich Text Area
|
|
38
|
+
// Encrypted Text Area
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const FEATURE_MULTI_PRODUCT_MIN_VERSION = "212.0.100";
|
|
42
|
+
var com;
|
|
43
|
+
if(com == null) com = {};
|
|
44
|
+
if(com.veeva == undefined)com.veeva = {};
|
|
45
|
+
com.veeva.clm = {
|
|
46
|
+
/////////////////////// Addresses ///////////////////////
|
|
47
|
+
|
|
48
|
+
// 1
|
|
49
|
+
// Returns an array of record IDs of all addresses (Address_vod__c) for a particular account (Account)
|
|
50
|
+
// account - specifies the record ID of the account of which to get all related addresses
|
|
51
|
+
// callback - call back function which will be used to return the information
|
|
52
|
+
getAddresses_Account: function(account, callback) {
|
|
53
|
+
ret = this.checkCallbackFunction(callback);
|
|
54
|
+
if(ret.success == false)
|
|
55
|
+
return ret;
|
|
56
|
+
|
|
57
|
+
// check arguments
|
|
58
|
+
ret = this.checkArgument("account", account);
|
|
59
|
+
if(ret.success == false) {
|
|
60
|
+
com.veeva.clm.wrapResult("getAddresses_Account", callback, ret);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
window["com_veeva_clm_accountAddresses"] = function(result) {
|
|
64
|
+
com.veeva.clm.wrapResult("getAddresses_Account", callback, result);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
query = "veeva:queryObject(Address_vod__c),fields(ID),where(WHERE Account_vod__c=\"" + account + "\"),com_veeva_clm_accountAddresses(result)";
|
|
68
|
+
if(!com.veeva.clm.testMode)
|
|
69
|
+
com.veeva.clm.runAPIRequest(query);
|
|
70
|
+
else
|
|
71
|
+
com_veeva_clm_accountAddresses(com.veeva.clm.testResult.common);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
// 2
|
|
75
|
+
// Returns the values of the specified fields for specified Address (Address_vod__c) record
|
|
76
|
+
// record - specifies the record ID of the Address to get fields from
|
|
77
|
+
// fields - list of field api names to return a value for, this parameter should be an array
|
|
78
|
+
// callback - call back function which will be used to return the information
|
|
79
|
+
getAddressFields: function(record, fields, callback) {
|
|
80
|
+
ret = this.checkCallbackFunction(callback);
|
|
81
|
+
if(ret.success == false)
|
|
82
|
+
return ret;
|
|
83
|
+
|
|
84
|
+
// check arguments
|
|
85
|
+
ret = this.checkArgument("record", record);
|
|
86
|
+
if(ret.success == false) {
|
|
87
|
+
com.veeva.clm.wrapResult("getAddressFields", callback, ret);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if(fields == undefined || fields == null) {
|
|
91
|
+
fields = ["ID"];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
window["com_veeva_clm_addressValues"] = function(result) {
|
|
95
|
+
com.veeva.clm.wrapResult("getAddressFields", callback, result);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
query = "veeva:queryObject(Address_vod__c),fields(" + this.joinFieldArray(fields) + "),where(WHERE IdNumber=\"" + record + "\"),com_veeva_clm_addressValues(result)";
|
|
99
|
+
if(!com.veeva.clm.testMode)
|
|
100
|
+
com.veeva.clm.runAPIRequest(query);
|
|
101
|
+
else
|
|
102
|
+
com_veeva_clm_addressValues(com.veeva.clm.testResult.common);
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
/////////////////////// Products ///////////////////////
|
|
107
|
+
|
|
108
|
+
// Returns an array of record IDs of all products (Product_vod__c) of a specified type that the User has access to
|
|
109
|
+
// type - specifies the Product Type (Product_Type_vod__c field on Product_vod__c)
|
|
110
|
+
// callback - call back function which will be used to return the information
|
|
111
|
+
getProduct_MySetup: function(type, callback) {
|
|
112
|
+
// check parameter
|
|
113
|
+
|
|
114
|
+
ret = this.checkCallbackFunction(callback);
|
|
115
|
+
if(ret.success == false)
|
|
116
|
+
return ret;
|
|
117
|
+
|
|
118
|
+
// check arguments
|
|
119
|
+
ret = this.checkArgument("type", type);
|
|
120
|
+
if(ret.success == false) {
|
|
121
|
+
com.veeva.clm.wrapResult("getProduct_MySetup", callback, ret);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
window["com_veeva_clm_productMysetup"] = function(result) {
|
|
127
|
+
com.veeva.clm.wrapResult("getProduct_MySetup", callback, result);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
query = "veeva:queryObject(Product_vod__c),fields(ID),where(WHERE Product_Type_vod__c=\"" + type + "\"),com_veeva_clm_productMysetup(result)";
|
|
132
|
+
if(!com.veeva.clm.testMode)
|
|
133
|
+
com.veeva.clm.runAPIRequest(query);
|
|
134
|
+
else
|
|
135
|
+
com_veeva_clm_productMysetup(com.veeva.clm.testResult.common);
|
|
136
|
+
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
/////////////////////// Record Type Support ///////////////////////
|
|
140
|
+
|
|
141
|
+
// Returns an array of record IDs of all RecordType records (RecordType) for a particular object
|
|
142
|
+
// object - specifies the API name of the object of which to get all active RecordTypes
|
|
143
|
+
// callback - call back function which will be used to return the information
|
|
144
|
+
getRecordType_Object: function(object, callback) {
|
|
145
|
+
|
|
146
|
+
ret = this.checkCallbackFunction(callback);
|
|
147
|
+
if(ret.success == false)
|
|
148
|
+
return ret;
|
|
149
|
+
|
|
150
|
+
// check arguments
|
|
151
|
+
ret = this.checkArgument("object", object);
|
|
152
|
+
if(ret.success == false) {
|
|
153
|
+
com.veeva.clm.wrapResult("getRecordType_Object", callback, ret);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
window["com_veeva_clm_objectRecordTypes"] = function(result) {
|
|
158
|
+
com.veeva.clm.wrapResult("getRecordType_Object", callback, result);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
query = "veeva:queryObject(RecordType),fields(ID),where(WHERE SobjectType=\"" + object + "\" and IsActive == YES),com_veeva_clm_objectRecordTypes(result)";
|
|
162
|
+
if(!com.veeva.clm.testMode)
|
|
163
|
+
com.veeva.clm.runAPIRequest(query);
|
|
164
|
+
else
|
|
165
|
+
com_veeva_clm_objectRecordTypes(com.veeva.clm.testResult.common);
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
/////////////////////// Surveys ///////////////////////
|
|
169
|
+
|
|
170
|
+
// 1
|
|
171
|
+
// Returns an array of record IDs of all Survey Questions (Survey_Question_vod__c) for a specific Survey (Survey_vod__c)
|
|
172
|
+
// Results are returned in ascending order based on the Order_vod__c field on Survey Question_vod__c.
|
|
173
|
+
// survey - specifies the record ID of the Survey to get all related Survey Questions from
|
|
174
|
+
// callback - call back function which will be used to return the information
|
|
175
|
+
getSurveyQuestions_Survey: function(survey, callback) {
|
|
176
|
+
ret = this.checkCallbackFunction(callback);
|
|
177
|
+
if(ret.success == false)
|
|
178
|
+
return ret;
|
|
179
|
+
|
|
180
|
+
// check arguments
|
|
181
|
+
ret = this.checkArgument("survey", survey);
|
|
182
|
+
if(ret.success == false) {
|
|
183
|
+
com.veeva.clm.wrapResult("getSurveyQuestions_Survey", callback, ret);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
window["com_veeva_clm_surveyQuestions"] = function(result) {
|
|
188
|
+
com.veeva.clm.wrapResult("getSurveyQuestions_Survey", callback, result);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
query = "veeva:queryObject(Survey_Question_vod__c),fields(ID),where(WHERE Survey_vod__c=\"" + survey + "\"),sort(Order_vod__c,asc),com_veeva_clm_surveyQuestions(result)";
|
|
192
|
+
if(!com.veeva.clm.testMode)
|
|
193
|
+
com.veeva.clm.runAPIRequest(query);
|
|
194
|
+
else
|
|
195
|
+
com_veeva_clm_surveyQuestions(com.veeva.clm.testResult.common);
|
|
196
|
+
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
// 2
|
|
200
|
+
// Returns an array of record IDs of all Questions Responses (Question_Response_vod__c object) for a specific Survey
|
|
201
|
+
// Target (Survey_Target_vod__c). Results are returned in ascending order based on the Order_vod__c field on Question_Response_vod__c.
|
|
202
|
+
// surveytarget - specifies the record ID of the Survey Target to get all related Question Responses from
|
|
203
|
+
// callback - call back function which will be used to return the information
|
|
204
|
+
getQuestionResponse_SurveyTarget: function(surveytarget, callback) {
|
|
205
|
+
ret = this.checkCallbackFunction(callback);
|
|
206
|
+
if(ret.success == false)
|
|
207
|
+
return ret;
|
|
208
|
+
|
|
209
|
+
// check arguments
|
|
210
|
+
ret = this.checkArgument("surveytarget", surveytarget);
|
|
211
|
+
if(ret.success == false) {
|
|
212
|
+
com.veeva.clm.wrapResult("getQuestionResponse_SurveyTarget", callback, ret);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
window["com_veeva_clm_targetResponses"] = function(result) {
|
|
216
|
+
com.veeva.clm.wrapResult("getQuestionResponse_SurveyTarget", callback, result);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
query = "veeva:queryObject(Question_Response_vod__c),fields(ID),where(WHERE Survey_Target_vod__c=\"" + surveytarget + "\"),sort(Order_vod__c,asc),com_veeva_clm_targetResponses(result)";
|
|
220
|
+
if(!com.veeva.clm.testMode)
|
|
221
|
+
com.veeva.clm.runAPIRequest(query);
|
|
222
|
+
else
|
|
223
|
+
com_veeva_clm_targetResponses(com.veeva.clm.testResult.common);
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
// 3
|
|
227
|
+
// Returns an array of record IDs of all Survey Targets (Survey_Target_vod__c) for a specific account (Account), for a
|
|
228
|
+
// specific Survey (Survey_vod__c)
|
|
229
|
+
// account - specifies the record ID of the Account to get all related Survey Targets from
|
|
230
|
+
// survey - specifies the record ID of the Survey to get all related Survey Targets from. Can be made optional by putting in "".
|
|
231
|
+
// callback - call back function which will be used to return the information
|
|
232
|
+
getSurveyTarget_Account: function(account, survey, callback) {
|
|
233
|
+
ret = this.checkCallbackFunction(callback);
|
|
234
|
+
if(ret.success == false)
|
|
235
|
+
return ret;
|
|
236
|
+
|
|
237
|
+
// check arguments
|
|
238
|
+
ret = this.checkArgument("account", account);
|
|
239
|
+
if(ret.success == false) {
|
|
240
|
+
com.veeva.clm.wrapResult("getSurveyTarget_Account", callback, ret);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
window["com_veeva_clm_accountSurveyTargets"] = function(result) {
|
|
245
|
+
com.veeva.clm.wrapResult("getSurveyTarget_Account", callback, result);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
query = null;
|
|
249
|
+
if(survey == null || survey == "") {
|
|
250
|
+
query = "veeva:queryObject(Survey_Target_vod__c),fields(ID),where(WHERE Account_vod__c=\"" + account + "\"),com_veeva_clm_accountSurveyTargets(result)";
|
|
251
|
+
} else {
|
|
252
|
+
query = "veeva:queryObject(Survey_Target_vod__c),fields(ID),where(WHERE Account_vod__c=\"" + account + "\" AND Survey_vod__c=\"" + survey + "\"),com_veeva_clm_accountSurveyTargets(result)";
|
|
253
|
+
}
|
|
254
|
+
if(!com.veeva.clm.testMode)
|
|
255
|
+
com.veeva.clm.runAPIRequest(query);
|
|
256
|
+
else
|
|
257
|
+
com_veeva_clm_accountSurveyTargets(com.veeva.clm.testResult.common);
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
/////////////////////// Order Management ///////////////////////
|
|
262
|
+
|
|
263
|
+
// * Campaign and Contract based Pricing Rules are not supported by the JavaScript Library for CLM Order Management functions"
|
|
264
|
+
// 1
|
|
265
|
+
// Returns an array of record IDs of all products (Product_vod__c) of type Order that have valid list prices
|
|
266
|
+
// Valid list price = Pricing Rule (Pricing_Rule_vod__c) of record type List Price (List_Price_Rule_vod) where current date is
|
|
267
|
+
// between Start Date (Start_Date_vod__c) and End Date (End_Date_vod__c)
|
|
268
|
+
// callback - call back function which will be used to return the information
|
|
269
|
+
// account/account group - specifies the record ID of an Account or the matching text for the Account Group. Can be made optional
|
|
270
|
+
// by putting in "". When utilized, returns an array of record IDs of all products (Product_vod__c) of type Order
|
|
271
|
+
// that have valid list price records which specify the Account or Account Group.
|
|
272
|
+
getProduct_OrderActive_Account: function(accountOrAccountGroup, callback) {
|
|
273
|
+
var orderProducts;
|
|
274
|
+
var ret = this.checkCallbackFunction(callback);
|
|
275
|
+
if(ret.success == false)
|
|
276
|
+
return ret;
|
|
277
|
+
|
|
278
|
+
// c, product
|
|
279
|
+
window["com_veeva_clm_ordersWithListPrice"] = function(result) {
|
|
280
|
+
result = com.veeva.clm.formatResult(result);
|
|
281
|
+
if(result.success) {
|
|
282
|
+
orderIds = [];
|
|
283
|
+
if(result.Pricing_Rule_vod__c && result.Pricing_Rule_vod__c.length > 0) {
|
|
284
|
+
for(i = 0; i < result.Pricing_Rule_vod__c.length; i++) {
|
|
285
|
+
orderIds.push(result.Pricing_Rule_vod__c[i].Product_vod__c);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
ret.success = true;
|
|
290
|
+
ret.Product_vod__c = orderIds;
|
|
291
|
+
com.veeva.clm.wrapResult("getProduct_OrderActive_Account", callback, ret);
|
|
292
|
+
} else {
|
|
293
|
+
com.veeva.clm.wrapResult("getProduct_OrderActive_Account", callback, result);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// b, got record type id
|
|
298
|
+
window["com_veeva_clm_listPriceTypeId"] = function(result) {
|
|
299
|
+
result = com.veeva.clm.formatResult(result);
|
|
300
|
+
if(result.success && result.RecordType && result.RecordType.length > 0) {
|
|
301
|
+
listPriceRecordTypeId = result.RecordType[0].ID;
|
|
302
|
+
|
|
303
|
+
// c, fetch product which has <list price> pricing rules
|
|
304
|
+
var ids = [];
|
|
305
|
+
for(i = 0; i < orderProducts.length; i++) {
|
|
306
|
+
ids.push(orderProducts[i].ID);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
dateString = com.veeva.clm.getCurrentDate();
|
|
310
|
+
|
|
311
|
+
query = null;
|
|
312
|
+
if(accountOrAccountGroup == null || accountOrAccountGroup == "") {
|
|
313
|
+
query = "veeva:queryObject(Pricing_Rule_vod__c),fields(ID,Product_vod__c),where(WHERE RecordTypeId=\"" + listPriceRecordTypeId + "\" AND Start_Date_vod__c <= \"" + dateString
|
|
314
|
+
+ "\" AND End_Date_vod__c >= \"" + dateString + "\" AND Product_vod__c IN " + com.veeva.clm.joinStringArrayForIn(ids) + "), com_veeva_clm_ordersWithListPrice(result)";
|
|
315
|
+
} else {
|
|
316
|
+
query = "veeva:queryObject(Pricing_Rule_vod__c),fields(ID,Product_vod__c),where(WHERE RecordTypeId=\"" + listPriceRecordTypeId + "\" AND (Account_vod__c=\"" + accountOrAccountGroup
|
|
317
|
+
+ "\" OR Account_Group_vod__c = \"" + accountOrAccountGroup + "\") AND Start_Date_vod__c <=\"" + dateString + "\" AND End_Date_vod__c >= \"" + dateString
|
|
318
|
+
+ "\" AND Product_vod__c IN " + com.veeva.clm.joinStringArrayForIn(ids) + "), com_veeva_clm_ordersWithListPrice(result)";
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if(!com.veeva.clm.testMode) {
|
|
322
|
+
com.veeva.clm.runAPIRequest(query);
|
|
323
|
+
} else {
|
|
324
|
+
com_veeva_clm_ordersWithListPrice(testResult.listPrices)
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
} else {
|
|
329
|
+
com.veeva.clm.wrapResult("getProduct_OrderActive_Account", callback, result);
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
// a, get order products
|
|
334
|
+
this.getProduct_MySetup("Order", function(result) {
|
|
335
|
+
// got the list order products,
|
|
336
|
+
if(result.success) {
|
|
337
|
+
|
|
338
|
+
orderProducts = result.Product_vod__c;
|
|
339
|
+
if(orderProducts && orderProducts.length > 0) {
|
|
340
|
+
// b, find out List Price record type id
|
|
341
|
+
recordTypeQuery = "veeva:queryObject(RecordType),fields(ID),where(WHERE SobjectType=\"Pricing_Rule_vod__c\" AND Name_vod__c=\"List_Price_Rule_vod\"),com_veeva_clm_listPriceTypeId(result)";
|
|
342
|
+
if(!com.veeva.clm.testMode)
|
|
343
|
+
com.veeva.clm.runAPIRequest(recordTypeQuery);
|
|
344
|
+
else
|
|
345
|
+
com_veeva_clm_listPriceTypeId(testResult.listPriceRecordType);
|
|
346
|
+
} else {
|
|
347
|
+
ret.success = true;
|
|
348
|
+
ret.Product_vod__c = [];
|
|
349
|
+
com.veeva.clm.wrapResult("getProduct_OrderActive_Account", callback, ret);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
} else {
|
|
353
|
+
// ERROR when geting Product of order type.
|
|
354
|
+
com.veeva.clm.wrapResult("getProduct_OrderActive_Account", callback, result);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
// 2
|
|
361
|
+
// Returns an array of record IDs of all products (Product_vod__c) of type Kit Component (Product_Type_vod__c field) who have
|
|
362
|
+
// parent product (Parent_Product_vod__c) = product
|
|
363
|
+
// product - specifies the record ID of the product of which to get all related Kit Components from
|
|
364
|
+
// callback - call back function which will be used to return the information
|
|
365
|
+
getProduct_KitComponents: function(product, callback) {
|
|
366
|
+
ret = this.checkCallbackFunction(callback);
|
|
367
|
+
if(ret.success == false)
|
|
368
|
+
return ret;
|
|
369
|
+
|
|
370
|
+
// check arguments
|
|
371
|
+
ret = this.checkArgument("product", product);
|
|
372
|
+
if(ret.success == false) {
|
|
373
|
+
com.veeva.clm.wrapResult("getProduct_KitComponents", callback, ret);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
window["com_veeva_clm_childKitItems"] = function(result) {
|
|
377
|
+
com.veeva.clm.wrapResult("getProduct_KitComponents", callback, result);
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
query = "veeva:queryObject(Product_vod__c),fields(ID),where(WHERE Product_Type_vod__c=\"Kit Item\" AND Parent_Product_vod__c=\"" + product + "\"),com_veeva_clm_childKitItems(result)";
|
|
382
|
+
if(!com.veeva.clm.testMode)
|
|
383
|
+
com.veeva.clm.runAPIRequest(query);
|
|
384
|
+
else
|
|
385
|
+
com_veeva_clm_childKitItems(com.veeva.clm.testResult.common);
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
// 3
|
|
389
|
+
// Returns an array of record IDs of Product Groups (Product_Group_vod__c) that the specified product (Product_vod__c) is part of
|
|
390
|
+
// product - specifies the record ID of the product of which to get all related Product Groups from
|
|
391
|
+
// callback - call back function which will be used to return the information
|
|
392
|
+
getProductGroup_Product: function(product, callback) {
|
|
393
|
+
ret = this.checkCallbackFunction(callback);
|
|
394
|
+
if(ret.success == false)
|
|
395
|
+
return ret;
|
|
396
|
+
|
|
397
|
+
// check arguments
|
|
398
|
+
ret = this.checkArgument("product", product);
|
|
399
|
+
if(ret.success == false) {
|
|
400
|
+
com.veeva.clm.wrapResult("getProductGroup_Product", callback, ret);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
window["com_veeva_clm_productProductGroups"] = function(result) {
|
|
404
|
+
result = com.veeva.clm.formatResult(result);
|
|
405
|
+
var ret = {};
|
|
406
|
+
if(result != null && result.success) {
|
|
407
|
+
var rows = result.Product_Group_vod__c;
|
|
408
|
+
var groupIds = [];
|
|
409
|
+
if(rows && rows.length > 0) {
|
|
410
|
+
for(i = 0; i < rows.length; i++) {
|
|
411
|
+
groupIds.push(rows[i].Product_Catalog_vod__c);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
ret.success = true;
|
|
416
|
+
ret.Product_vod__c = groupIds;
|
|
417
|
+
|
|
418
|
+
com.veeva.clm.wrapResult("getProductGroup_Product", callback, ret);
|
|
419
|
+
} else if(result != null) {
|
|
420
|
+
com.veeva.clm.wrapResult("getProductGroup_Product", callback, result);
|
|
421
|
+
} else {
|
|
422
|
+
// is not expected from low-level API
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
query = "veeva:queryObject(Product_Group_vod__c),fields(ID,Product_Catalog_vod__c),where(WHERE Product_vod__c=\"" + product + "\"),com_veeva_clm_productProductGroups(result)";
|
|
428
|
+
if(!com.veeva.clm.testMode)
|
|
429
|
+
com.veeva.clm.runAPIRequest(query);
|
|
430
|
+
else
|
|
431
|
+
com_veeva_clm_productProductGroups(com.veeva.clm.testResult.common);
|
|
432
|
+
},
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
// 4
|
|
436
|
+
// Returns an array of record IDs of the last 10 Orders (Order_vod__c) for a particular account (Account)
|
|
437
|
+
// The order of last ten orders is based on the field Order_Date_vod__c, descending.
|
|
438
|
+
// account - specifies the record ID of the account of which to get all related orders
|
|
439
|
+
// callback - call back function which will be used to return the information
|
|
440
|
+
getLastTenOrders_Account: function(account, callback) {
|
|
441
|
+
ret = this.checkCallbackFunction(callback);
|
|
442
|
+
if(ret.success == false)
|
|
443
|
+
return ret;
|
|
444
|
+
|
|
445
|
+
// check arguments
|
|
446
|
+
ret = this.checkArgument("account", account);
|
|
447
|
+
if(ret.success == false) {
|
|
448
|
+
com.veeva.clm.wrapResult("getLastTenOrders_Account", callback, ret);
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
window["com_veeva_clm_accountLastTenOrders"] = function(result) {
|
|
453
|
+
com.veeva.clm.wrapResult("getLastTenOrders_Account", callback, result);
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
query = "veeva:queryObject(Order_vod__c),fields(ID),where(WHERE Account_vod__c=\"" + account + "\"),sort(Order_Date_vod__c,desc),limit(10),com_veeva_clm_accountLastTenOrders(result)";
|
|
458
|
+
if(!com.veeva.clm.testMode)
|
|
459
|
+
com.veeva.clm.runAPIRequest(query);
|
|
460
|
+
else
|
|
461
|
+
com_veeva_clm_accountLastTenOrders(com.veeva.clm.testResult.common);
|
|
462
|
+
},
|
|
463
|
+
|
|
464
|
+
// 5
|
|
465
|
+
// Returns an array of record IDs of all Order Lines (Order_Line_vod__c) for a particular order (Order_vod__c)
|
|
466
|
+
// order - specifies the record ID of the order of which to get all related order lines
|
|
467
|
+
// callback - call back function which will be used to return the information
|
|
468
|
+
getOrderLines_Order: function(order, callback) {
|
|
469
|
+
ret = this.checkCallbackFunction(callback);
|
|
470
|
+
if(ret.success == false)
|
|
471
|
+
return ret;
|
|
472
|
+
|
|
473
|
+
// check arguments
|
|
474
|
+
ret = this.checkArgument("order", order);
|
|
475
|
+
if(ret.success == false) {
|
|
476
|
+
com.veeva.clm.wrapResult("getOrderLines_Order", callback, ret);
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
window["com_veeva_clm_orderLines"] = function(result) {
|
|
480
|
+
com.veeva.clm.wrapResult("getOrderLines_Order", callback, result);
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
query = "veeva:queryObject(Order_Line_vod__c),fields(ID),where(WHERE Order_vod__c=\"" + order + "\"),com_veeva_clm_orderLines(result)";
|
|
485
|
+
if(!com.veeva.clm.testMode)
|
|
486
|
+
com.veeva.clm.runAPIRequest(query);
|
|
487
|
+
else
|
|
488
|
+
com_veeva_clm_orderLines(com.veeva.clm.testResult.common);
|
|
489
|
+
},
|
|
490
|
+
|
|
491
|
+
// 6
|
|
492
|
+
// DEPRECATED - Please use getListPrice_Product_Account
|
|
493
|
+
// Returns an array of record IDs for the currently valid List Price (Pricing_Rule_vod__c) for a specific product (Product_vod__c)
|
|
494
|
+
// Valid list price = Pricing Rule (Pricing_Rule_vod__c) of record type List Price (List_Price_Rule_vod) where current date is
|
|
495
|
+
// between Start Date (Start_Date_vod__c) and End Date (End_Date_vod__c)
|
|
496
|
+
// product - specifies the record ID of the product of which to get the List Price for
|
|
497
|
+
// callback - call back function which will be used to return the information
|
|
498
|
+
getListPrice_Product: function(product, callback) {
|
|
499
|
+
ret = this.checkCallbackFunction(callback);
|
|
500
|
+
if(ret.success == false)
|
|
501
|
+
return ret;
|
|
502
|
+
|
|
503
|
+
// check arguments
|
|
504
|
+
ret = this.checkArgument("product", product);
|
|
505
|
+
if(ret.success == false) {
|
|
506
|
+
com.veeva.clm.wrapResult("getListPrice_Product", callback, ret);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
window["com_veeva_clm_productPricingRules"] = function(result) {
|
|
512
|
+
com.veeva.clm.wrapResult("getListPrice_Product", callback, result);
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
// 2
|
|
516
|
+
window["com_veeva_clm_listPriceTypeId_getListPrice_Product"] = function(result) {
|
|
517
|
+
result = com.veeva.clm.formatResult(result);
|
|
518
|
+
if(result.success && result.RecordType && result.RecordType.length > 0) {
|
|
519
|
+
listPriceRecordTypeId = result.RecordType[0].ID;
|
|
520
|
+
|
|
521
|
+
// 2.1, fetch pricing rules for the product
|
|
522
|
+
|
|
523
|
+
dateString = com.veeva.clm.getCurrentDate();
|
|
524
|
+
query = "veeva:queryObject(Pricing_Rule_vod__c),fields(ID),where(WHERE RecordTypeId=\"" + listPriceRecordTypeId + "\" AND Product_vod__c = \"" + product + "\""
|
|
525
|
+
+ " AND Start_Date_vod__c <= \"" + dateString + "\" AND End_Date_vod__c >= \"" + dateString + "\"), com_veeva_clm_productPricingRules(result)";
|
|
526
|
+
if(!com.veeva.clm.testMode)
|
|
527
|
+
com.veeva.clm.runAPIRequest(query);
|
|
528
|
+
else
|
|
529
|
+
com_veeva_clm_productPricingRules(com.veeva.clm.testResult.listPrices);
|
|
530
|
+
} else {
|
|
531
|
+
com.veeva.clm.wrapResult("getListPrice_Product", callback, result);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
// 1, fetch list price record type first
|
|
537
|
+
recordTypeQuery = "veeva:queryObject(RecordType),fields(ID),where(WHERE SobjectType=\"Pricing_Rule_vod__c\" AND Name_vod__c=\"List_Price_Rule_vod\"),com_veeva_clm_listPriceTypeId_getListPrice_Product(result)";
|
|
538
|
+
if(!com.veeva.clm.testMode)
|
|
539
|
+
com.veeva.clm.runAPIRequest(recordTypeQuery);
|
|
540
|
+
else
|
|
541
|
+
com_veeva_clm_listPriceTypeId_getListPrice_Product(testResult.listPriceRecordType);
|
|
542
|
+
|
|
543
|
+
},
|
|
544
|
+
|
|
545
|
+
// 7
|
|
546
|
+
// Requires that an Account be specified in order for any result to be returned.
|
|
547
|
+
// Returns the record ID for the currently valid List Price (Pricing_Rule_vod__c) for a specific product (Product_vod__c) and Account combination. Respects the Account and Account Group List Price hierarchy.
|
|
548
|
+
// Valid list price = Pricing Rule (Pricing_Rule_vod__c) of record type List Price (List_Price_Rule_vod) where current date is between Start Date (Start_Date_vod__c) and End Date (End_Date_vod__c)
|
|
549
|
+
// product - specifies the record ID of the product of which to get the Pricing Rule for
|
|
550
|
+
// account - specifies the Account for which to select List Prices for
|
|
551
|
+
// callback - call back function which will be used to return the information
|
|
552
|
+
getListPrice_Product_Account: function(product, account, callback) {
|
|
553
|
+
ret = this.checkCallbackFunction(callback);
|
|
554
|
+
if(ret.success == false)
|
|
555
|
+
return ret;
|
|
556
|
+
|
|
557
|
+
// check arguments
|
|
558
|
+
ret = this.checkArgument("product", product);
|
|
559
|
+
if(ret.success == false) {
|
|
560
|
+
com.veeva.clm.wrapResult("getListPrice_Product_Account", callback, ret);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
ret = this.checkArgument("account", account);
|
|
564
|
+
if(ret.success == false) {
|
|
565
|
+
com.veeva.clm.wrapResult("getListPrice_Product_Account", callback, ret);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
window["com_veeva_clm_productDefaultPricingRules"] = function(result) {
|
|
570
|
+
com.veeva.clm.wrapResult("getListPrice_Product_Account", callback, result);
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
window["com_veeva_clm_get_productDefaultPricingRules"] = function() {
|
|
574
|
+
|
|
575
|
+
dateString = com.veeva.clm.getCurrentDate();
|
|
576
|
+
groupQuery = "veeva:queryObject(Pricing_Rule_vod__c),fields(ID),where(WHERE RecordTypeId=\"" + listPriceRecordTypeId + "\" AND Product_vod__c = \"" + product + "\""
|
|
577
|
+
+ " AND Account_Group_vod__c=\"\" AND Account_vod__c=\"\""
|
|
578
|
+
+ " AND Start_Date_vod__c <= \"" + dateString + "\" AND End_Date_vod__c >= \"" + dateString + "\"), com_veeva_clm_productDefaultPricingRules(result)";
|
|
579
|
+
if(!com.veeva.clm.testMode)
|
|
580
|
+
com.veeva.clm.runAPIRequest(groupQuery);
|
|
581
|
+
else {
|
|
582
|
+
// TODO
|
|
583
|
+
com_veeva_clm_productDefaultPricingRules(com.veeva.clm.testResult.listPrices);
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
window["com_veeva_clm_productAccountGroupPricingRules"] = function(result) {
|
|
588
|
+
result = com.veeva.clm.formatResult(result);
|
|
589
|
+
if(result.success && result.Pricing_Rule_vod__c.length == 0) {
|
|
590
|
+
// try account group
|
|
591
|
+
com_veeva_clm_get_productDefaultPricingRules();
|
|
592
|
+
}
|
|
593
|
+
else
|
|
594
|
+
com.veeva.clm.wrapResult("getListPrice_Product_Account", callback, result);
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
// 4 pricing rule for account group
|
|
598
|
+
window['com_veeva_clm_accountGroup'] = function(result) {
|
|
599
|
+
result = com.veeva.clm.formatResult(result);
|
|
600
|
+
if(result.success) {
|
|
601
|
+
accountGroup = result.Account.Account_Group_vod__c;
|
|
602
|
+
if(accountGroup != undefined && accountGroup != "") {
|
|
603
|
+
dateString = com.veeva.clm.getCurrentDate();
|
|
604
|
+
groupQuery = "veeva:queryObject(Pricing_Rule_vod__c),fields(ID),where(WHERE RecordTypeId=\"" + listPriceRecordTypeId + "\" AND Product_vod__c = \"" + product + "\""
|
|
605
|
+
+ " AND Account_Group_vod__c=\"" + accountGroup + "\""
|
|
606
|
+
+ " AND Start_Date_vod__c <= \"" + dateString + "\" AND End_Date_vod__c >= \"" + dateString + "\"), com_veeva_clm_productAccountGroupPricingRules(result)";
|
|
607
|
+
if(!com.veeva.clm.testMode)
|
|
608
|
+
com.veeva.clm.runAPIRequest(groupQuery);
|
|
609
|
+
else {
|
|
610
|
+
// TODO
|
|
611
|
+
com_veeva_clm_productAccountGroupPricingRules(com.veeva.clm.testResult.listPrices);
|
|
612
|
+
}
|
|
613
|
+
} else {
|
|
614
|
+
com_veeva_clm_get_productDefaultPricingRules();
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
com.veeva.clm.wrapResult("getListPrice_Product_Account", callback, result);
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
// 3 account group
|
|
623
|
+
window["com_veeva_clm_productAccountPricingRules"] = function(result) {
|
|
624
|
+
result = com.veeva.clm.formatResult(result);
|
|
625
|
+
if(result.success && result.Pricing_Rule_vod__c.length == 0) {
|
|
626
|
+
// try account group
|
|
627
|
+
com.veeva.clm.getDataForObject("Account", account, "Account_Group_vod__c", com_veeva_clm_accountGroup);
|
|
628
|
+
}
|
|
629
|
+
else
|
|
630
|
+
com.veeva.clm.wrapResult("getListPrice_Product_Account", callback, result);
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
// 2
|
|
634
|
+
window["com_veeva_clm_listPriceTypeId_getListPrice_Product_Account"] = function(result) {
|
|
635
|
+
result = com.veeva.clm.formatResult(result);
|
|
636
|
+
if(result.success && result.RecordType && result.RecordType.length > 0) {
|
|
637
|
+
listPriceRecordTypeId = result.RecordType[0].ID;
|
|
638
|
+
|
|
639
|
+
dateString = com.veeva.clm.getCurrentDate();
|
|
640
|
+
query = "veeva:queryObject(Pricing_Rule_vod__c),fields(ID),where(WHERE RecordTypeId=\"" + listPriceRecordTypeId + "\" AND Product_vod__c = \"" + product + "\""
|
|
641
|
+
+ " AND Account_vod__c=\"" + account + "\""
|
|
642
|
+
+ " AND Start_Date_vod__c <= \"" + dateString + "\" AND End_Date_vod__c >= \"" + dateString + "\"), com_veeva_clm_productAccountPricingRules(result)";
|
|
643
|
+
|
|
644
|
+
if(!com.veeva.clm.testMode)
|
|
645
|
+
com.veeva.clm.runAPIRequest(query);
|
|
646
|
+
else
|
|
647
|
+
com_veeva_clm_productAccountPricingRules(com.veeva.clm.testResult.listPrices);
|
|
648
|
+
} else {
|
|
649
|
+
com.veeva.clm.wrapResult("getListPrice_Product_Account", callback, result);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
// 1, fetch list price record type first
|
|
655
|
+
recordTypeQuery = "veeva:queryObject(RecordType),fields(ID),where(WHERE SobjectType=\"Pricing_Rule_vod__c\" AND Name_vod__c=\"List_Price_Rule_vod\"),com_veeva_clm_listPriceTypeId_getListPrice_Product_Account(result)";
|
|
656
|
+
if(!com.veeva.clm.testMode)
|
|
657
|
+
com.veeva.clm.runAPIRequest(recordTypeQuery);
|
|
658
|
+
else
|
|
659
|
+
com_veeva_clm_listPriceTypeId_getListPrice_Product_Account(testResult.listPriceRecordType);
|
|
660
|
+
|
|
661
|
+
},
|
|
662
|
+
|
|
663
|
+
/////////////////////// Generate Dynamic Content ///////////////////////
|
|
664
|
+
// Generate Content Dynamically for personalized version from a document template (DCT)
|
|
665
|
+
// returns id of Veeva Content record upon success
|
|
666
|
+
// vaultId: Specifies the Vault Instance ID of the Dynamic Content Template
|
|
667
|
+
// documentNum: Specifies the Vault Document ID of the Dynamic Content Template
|
|
668
|
+
// account: Specifies the record ID of the account the values are related to
|
|
669
|
+
// expiryPeriod: Specifies the number of days the generated dynamic content will be available for (optional)
|
|
670
|
+
// allowDownload: Specifies if the content can be downloaded; Boolean true or false, default to false
|
|
671
|
+
// displayName: Specifies the file name that displays when rendering the generated dynamic content
|
|
672
|
+
// values: Json object with the fields and values to be resolved in the Personalized Version (PV) of the DCT
|
|
673
|
+
// callback: Callback function used to return the information
|
|
674
|
+
//
|
|
675
|
+
generateDynamicContent: function(vaultId, documentNum, account, expiryPeriod, allowDownload, displayName, values, callback) {
|
|
676
|
+
// check callback parameter
|
|
677
|
+
ret = this.checkCallbackFunction(callback);
|
|
678
|
+
if(ret.success == false) {
|
|
679
|
+
return ret;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// check arguments
|
|
683
|
+
ret = this.checkArgument("vaultId", vaultId);
|
|
684
|
+
if(ret.success == false) {
|
|
685
|
+
com.veeva.clm.wrapResult("generateDynamicContent", callback, ret);
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
ret = this.checkArgument("documentNum", documentNum);
|
|
690
|
+
if(ret.success == false) {
|
|
691
|
+
com.veeva.clm.wrapResult("generateDynamicContent", callback, ret);
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
ret = this.checkArgument("account", account);
|
|
696
|
+
if(ret.success == false) {
|
|
697
|
+
com.veeva.clm.wrapResult("generateDynamicContent", callback, ret);
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
ret = this.checkArgument("displayName", displayName);
|
|
702
|
+
if(ret.success == false) {
|
|
703
|
+
com.veeva.clm.wrapResult("generateDynamicContent", callback, ret);
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
ret = this.checkArgument("values", values);
|
|
708
|
+
if(ret.success == false) {
|
|
709
|
+
com.veeva.clm.wrapResult("generateDynamicContent", callback, ret);
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
parameters = {};
|
|
714
|
+
parameters.vaultId = vaultId;
|
|
715
|
+
parameters.documentNum = documentNum;
|
|
716
|
+
parameters.account = account;
|
|
717
|
+
parameters.allowDownload = allowDownload === true ? true : false;
|
|
718
|
+
parameters.displayName = displayName
|
|
719
|
+
parameters.values = values
|
|
720
|
+
|
|
721
|
+
// add expiryPeriod, an optional parameter if it is a valid number
|
|
722
|
+
if (!Number.isNaN(Number(expiryPeriod))) {
|
|
723
|
+
parameters.expiryPeriod = expiryPeriod;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
window["com_veeva_clm_generateDynamicContent"] = function(result) {
|
|
727
|
+
ret = com.veeva.clm.formatResult(result);
|
|
728
|
+
com.veeva.clm.wrapResult("generateDynamicContent", callback, ret);
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
request = "veeva:generateDynamicContent(" + JSON.stringify(parameters) + ")" + ",callback(com_veeva_clm_generateDynamicContent)";
|
|
732
|
+
if(!com.veeva.clm.testMode) {
|
|
733
|
+
com.veeva.clm.runAPIRequest(request);
|
|
734
|
+
} else {
|
|
735
|
+
com_veeva_clm_generateDynamicContent(com.veeva.clm.testResult.dynamicContentResult);
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
|
|
739
|
+
/////////////////////// Approved Email ///////////////////////
|
|
740
|
+
|
|
741
|
+
// Returns the record ID(s) for the Approved Document which matches the values specified and Status_vod = Approved
|
|
742
|
+
// Gets the approved document by querying all products of type Detail Topic or Detail and compares against
|
|
743
|
+
// the query of any approved documents with the passed in vault_id and
|
|
744
|
+
// document_num. If there are multiple documents with these same ids, an error is thrown.
|
|
745
|
+
// vault_id - specifies the Vault ID of the Approved Document to retrieve. (Vault_Instance_ID_vod on Approved_Document_vod)
|
|
746
|
+
// document_num - specifies the document number of the Approved Document to retrieve. (Vault_Document_ID_vod on Approved_Document_vod)
|
|
747
|
+
// callback - call back function which will be used to return the information
|
|
748
|
+
getApprovedDocument: function(vault_id, document_num, callback) {
|
|
749
|
+
var topicProducts;
|
|
750
|
+
var detailProducts;
|
|
751
|
+
var detailGroupProducts;
|
|
752
|
+
var productGroups;
|
|
753
|
+
|
|
754
|
+
// check callback parameter
|
|
755
|
+
ret = this.checkCallbackFunction(callback);
|
|
756
|
+
if(ret.success == false)
|
|
757
|
+
return ret;
|
|
758
|
+
|
|
759
|
+
// check arguments
|
|
760
|
+
ret = this.checkArgument("vault_id", vault_id);
|
|
761
|
+
if(ret.success == false) {
|
|
762
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, ret);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
ret = this.checkArgument("document_num", document_num);
|
|
767
|
+
if(ret.success == false) {
|
|
768
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, ret);
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
// check version
|
|
773
|
+
this.getAppVersion(function(result) {
|
|
774
|
+
var isFeatureMultiProductSupported = false;
|
|
775
|
+
if (result.success) {
|
|
776
|
+
var version = result.Version;
|
|
777
|
+
// compare the version
|
|
778
|
+
var n = FEATURE_MULTI_PRODUCT_MIN_VERSION.localeCompare(version);
|
|
779
|
+
// returns -1 if the min version is before the current version
|
|
780
|
+
// returns 0 if the two versions are equal
|
|
781
|
+
// returns 1 if the min version is after the current version
|
|
782
|
+
if (n < 1) {
|
|
783
|
+
isFeatureMultiProductSupported = true;
|
|
784
|
+
//If the current version is compatible, run the request veeva:getApprovedDocument to get the document
|
|
785
|
+
//Otherwise, we just run existing js logic to return the document
|
|
786
|
+
window["com_veeva_clm_approvedDocument"] = function(result) {
|
|
787
|
+
result = com.veeva.clm.formatResult(result);
|
|
788
|
+
if (result.success && result.ApprovedDocumentId) {
|
|
789
|
+
var ret = {};
|
|
790
|
+
ret.Approved_Document_vod__c = {};
|
|
791
|
+
ret.Approved_Document_vod__c.ID = result.ApprovedDocumentId;
|
|
792
|
+
ret.success = true;
|
|
793
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, ret);
|
|
794
|
+
return;
|
|
795
|
+
} else {
|
|
796
|
+
var ret = {};
|
|
797
|
+
ret.success = false;
|
|
798
|
+
if(result.code != undefined){
|
|
799
|
+
ret.code = result.code;
|
|
800
|
+
}
|
|
801
|
+
if(result.message != undefined){
|
|
802
|
+
ret.message = result.message;
|
|
803
|
+
}
|
|
804
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, ret);
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
query = "veeva:getApprovedDocument(" + vault_id + "," + document_num + "),com_veeva_clm_approvedDocument(result)";
|
|
810
|
+
if (!com.veeva.clm.testMode)
|
|
811
|
+
com.veeva.clm.runAPIRequest(query);
|
|
812
|
+
else
|
|
813
|
+
com_veeva_clm_appVersion(com.veeva.clm.testResult.common);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
if( isFeatureMultiProductSupported == false) {
|
|
818
|
+
// existing js logic to return the document
|
|
819
|
+
// 2b Check results of Approved Document query against My Setup results
|
|
820
|
+
window["com_veeva_clm_DocumentTypeId_getDocument"] = function(result) {
|
|
821
|
+
result = com.veeva.clm.formatResult(result);
|
|
822
|
+
|
|
823
|
+
if(result.success && result.Approved_Document_vod__c && result.Approved_Document_vod__c.length == 1) {
|
|
824
|
+
var productsWithDetailGroups;
|
|
825
|
+
|
|
826
|
+
//If we have access to detail groups, align products with detail groups
|
|
827
|
+
if(detailGroupProducts != undefined && productGroups != undefined && productGroups.length > 0) {
|
|
828
|
+
productsWithDetailGroups = [];
|
|
829
|
+
var groupCount = 0;
|
|
830
|
+
for(var i = 0; i < detailGroupProducts.length; i++) {
|
|
831
|
+
for(var j = 0; j < productGroups.length; j++) {
|
|
832
|
+
//If the detail group product ID matches the product group's Product Catalog ID
|
|
833
|
+
//AND it is the product we are looking for, add it
|
|
834
|
+
if(detailGroupProducts[i].ID != undefined
|
|
835
|
+
&& productGroups[j].Product_Catalog_vod__c != undefined
|
|
836
|
+
&& productGroups[j].Product_vod__c != undefined
|
|
837
|
+
&& detailGroupProducts[i].ID == productGroups[j].Product_Catalog_vod__c
|
|
838
|
+
&& result.Approved_Document_vod__c[0].Product_vod__c == productGroups[j].Product_vod__c) {
|
|
839
|
+
productsWithDetailGroups[groupCount] = {};
|
|
840
|
+
productsWithDetailGroups[groupCount].ID = {};
|
|
841
|
+
productsWithDetailGroups[groupCount].Detail_Group_vod__c = {};
|
|
842
|
+
productsWithDetailGroups[groupCount].ID = productGroups[j].Product_vod__c;
|
|
843
|
+
productsWithDetailGroups[groupCount].Detail_Group_vod__c = detailGroupProducts[i].ID;
|
|
844
|
+
groupCount++;
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
if(topicProducts && topicProducts.length > 0) {
|
|
852
|
+
//Check against the detail topics for a valid product match
|
|
853
|
+
for(var j = 0; j < topicProducts.length; j++) {
|
|
854
|
+
if(result.Approved_Document_vod__c[0].Product_vod__c === topicProducts[j].ID) {
|
|
855
|
+
//If we have product groups that match our current product, run through them
|
|
856
|
+
//Otherwise, we just have a product w/o detail groups, so return the document
|
|
857
|
+
if(productsWithDetailGroups != undefined && productsWithDetailGroups.length > 0) {
|
|
858
|
+
for(var i = 0; i < productsWithDetailGroups.length; i++) {
|
|
859
|
+
if(result.Approved_Document_vod__c[0].Detail_Group_vod__c != undefined
|
|
860
|
+
&& result.Approved_Document_vod__c[0].Product_vod__c == productsWithDetailGroups[i].ID
|
|
861
|
+
&& result.Approved_Document_vod__c[0].Detail_Group_vod__c == productsWithDetailGroups[i].Detail_Group_vod__c) {
|
|
862
|
+
var ret = {};
|
|
863
|
+
ret.Approved_Document_vod__c = {};
|
|
864
|
+
ret.Approved_Document_vod__c.ID = result.Approved_Document_vod__c[0].ID;
|
|
865
|
+
ret.success = true;
|
|
866
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, ret);
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
else {
|
|
872
|
+
var ret = {};
|
|
873
|
+
ret.Approved_Document_vod__c = {};
|
|
874
|
+
ret.Approved_Document_vod__c.ID = result.Approved_Document_vod__c[0].ID;
|
|
875
|
+
ret.success = true;
|
|
876
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, ret);
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
if(detailProducts && detailProducts.length > 0) {
|
|
883
|
+
//Check against the details for a valid product match
|
|
884
|
+
for(var k = 0; k < detailProducts.length; k++) {
|
|
885
|
+
if(result.Approved_Document_vod__c[0].Product_vod__c === detailProducts[k].ID) {
|
|
886
|
+
//If we have product groups that match our current product, run through them
|
|
887
|
+
//Otherwise, we just have a product w/o detail groups, so return the document
|
|
888
|
+
if(productsWithDetailGroups != undefined && productsWithDetailGroups.length > 0) {
|
|
889
|
+
for(var i = 0; i < productsWithDetailGroups.length; i++) {
|
|
890
|
+
if(result.Approved_Document_vod__c[0].Detail_Group_vod__c != undefined
|
|
891
|
+
&& result.Approved_Document_vod__c[0].Product_vod__c == productsWithDetailGroups[i].ID
|
|
892
|
+
&& result.Approved_Document_vod__c[0].Detail_Group_vod__c == productsWithDetailGroups[i].Detail_Group_vod__c) {
|
|
893
|
+
var ret = {};
|
|
894
|
+
ret.Approved_Document_vod__c = {};
|
|
895
|
+
ret.Approved_Document_vod__c.ID = result.Approved_Document_vod__c[0].ID;
|
|
896
|
+
ret.success = true;
|
|
897
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, ret);
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
else {
|
|
903
|
+
var ret = {};
|
|
904
|
+
ret.Approved_Document_vod__c = {};
|
|
905
|
+
ret.Approved_Document_vod__c.ID = result.Approved_Document_vod__c[0].ID;
|
|
906
|
+
ret.success = true;
|
|
907
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, ret);
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
//Found no match, return empty object
|
|
914
|
+
var ret = {};
|
|
915
|
+
ret.success = true;
|
|
916
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, ret);
|
|
917
|
+
}
|
|
918
|
+
//Query success, but we found more than one doc with the same vault id and doc num, so return empty
|
|
919
|
+
else if(result.success && result.Approved_Document_vod__c && result.Approved_Document_vod__c.length > 1) {
|
|
920
|
+
var ret = {};
|
|
921
|
+
ret.success = true;
|
|
922
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, ret);
|
|
923
|
+
}
|
|
924
|
+
else {
|
|
925
|
+
if(result.code == 1021) {
|
|
926
|
+
if(result.message.indexOf("Detail_Group_vod__c") >= 0) {
|
|
927
|
+
approvedDocumentQuery = "veeva:queryObject(Approved_Document_vod__c),fields(ID,Product_vod__c),where(WHERE Vault_Instance_ID_vod__c=\"" + vault_id
|
|
928
|
+
+ "\" AND Vault_Document_ID_vod__c=\"" + document_num + "\" AND Status_vod__c=\"Approved_vod\"),com_veeva_clm_DocumentTypeId_getDocument(result)";
|
|
929
|
+
|
|
930
|
+
if(!com.veeva.clm.testMode)
|
|
931
|
+
com.veeva.clm.runAPIRequest(approvedDocumentQuery);
|
|
932
|
+
else
|
|
933
|
+
com_veeva_clm_DocumentTypeId_getDocument(testResult.approvedDocumentWithId2);
|
|
934
|
+
}
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
//Didn't find anything matching, return empty object with success true (not just an empty query object)
|
|
939
|
+
var ret = {};
|
|
940
|
+
ret.success = true;
|
|
941
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, ret);
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
// 2a - If we have detail groups, get the product groups so we can align products to detail groups
|
|
946
|
+
window["com_veeva_clm_getProductGroups"] = function(result) {
|
|
947
|
+
result = com.veeva.clm.formatResult(result);
|
|
948
|
+
|
|
949
|
+
if(result.success) {
|
|
950
|
+
productGroups = result.Product_Group_vod__c;
|
|
951
|
+
|
|
952
|
+
approvedDocumentQuery = "veeva:queryObject(Approved_Document_vod__c),fields(ID,Product_vod__c,Detail_Group_vod__c),where(WHERE Vault_Instance_ID_vod__c=\"" + vault_id + "\" AND Vault_Document_ID_vod__c=\"" + document_num + "\" AND Status_vod__c=\"Approved_vod\"),com_veeva_clm_DocumentTypeId_getDocument(result)";
|
|
953
|
+
|
|
954
|
+
if(!com.veeva.clm.testMode)
|
|
955
|
+
com.veeva.clm.runAPIRequest(approvedDocumentQuery);
|
|
956
|
+
else
|
|
957
|
+
com_veeva_clm_DocumentTypeId_getDocument(testResult.approvedDocumentWithId);
|
|
958
|
+
}
|
|
959
|
+
else {
|
|
960
|
+
if(result.code == 1011) {
|
|
961
|
+
//No access to Product Groups specifically, so just use Products
|
|
962
|
+
if(result.message.indexOf("Product_Group_vod__c") >= 0) {
|
|
963
|
+
approvedDocumentQuery = "veeva:queryObject(Approved_Document_vod__c),fields(ID,Product_vod__c),where(WHERE Vault_Instance_ID_vod__c=\"" + vault_id + "\" AND Vault_Document_ID_vod__c=\"" + document_num + "\" AND Status_vod__c=\"Approved_vod\"),com_veeva_clm_DocumentTypeId_getDocument(result)";
|
|
964
|
+
|
|
965
|
+
if(!com.veeva.clm.testMode)
|
|
966
|
+
com.veeva.clm.runAPIRequest(approvedDocumentQuery);
|
|
967
|
+
else
|
|
968
|
+
com_veeva_clm_DocumentTypeId_getDocument(testResult.approvedDocumentWithId2);
|
|
969
|
+
}
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, result);
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
// 1, get detail topic products first
|
|
977
|
+
com.veeva.clm.getProduct_MySetup("Detail Topic", function(result) {
|
|
978
|
+
result = com.veeva.clm.formatResult(result);
|
|
979
|
+
|
|
980
|
+
// got a list of detail topic products
|
|
981
|
+
if(result.success) {
|
|
982
|
+
topicProducts = result.Product_vod__c;
|
|
983
|
+
|
|
984
|
+
com.veeva.clm.getProduct_MySetup("Detail", function(result) {
|
|
985
|
+
if(result.success) {
|
|
986
|
+
detailProducts = result.Product_vod__c;
|
|
987
|
+
|
|
988
|
+
com.veeva.clm.getProduct_MySetup("Detail Group", function(result) {
|
|
989
|
+
if(result.success) {
|
|
990
|
+
detailGroupProducts = result.Product_vod__c;
|
|
991
|
+
|
|
992
|
+
var detailGroupIDs = [];
|
|
993
|
+
for(var i = 0; i < detailGroupProducts.length; i++) {
|
|
994
|
+
detailGroupIDs[i] = detailGroupProducts[i].ID;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
var groupArray = com.veeva.clm.joinStringArrayForIn(detailGroupIDs);
|
|
998
|
+
if(groupArray == "") {
|
|
999
|
+
groupArray = "{}";
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
//Pass in our detail groups and find any products associated with them
|
|
1003
|
+
query = "veeva:queryObject(Product_Group_vod__c),fields(ID,Product_vod__c,Product_Catalog_vod__c),where(WHERE Product_Catalog_vod__c IN " + groupArray + "),com_veeva_clm_getProductGroups(result)";
|
|
1004
|
+
if(!com.veeva.clm.testMode)
|
|
1005
|
+
com.veeva.clm.runAPIRequest(query);
|
|
1006
|
+
else
|
|
1007
|
+
com_veeva_clm_getProductGroups(com.veeva.clm.testResult.productGroups);
|
|
1008
|
+
|
|
1009
|
+
}
|
|
1010
|
+
else {
|
|
1011
|
+
// ERROR when getting Product of detail group type.
|
|
1012
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, result);
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
else {
|
|
1018
|
+
// ERROR when getting Product of detail type.
|
|
1019
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, result);
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
} else {
|
|
1024
|
+
// ERROR when getting Product of detail topic type.
|
|
1025
|
+
com.veeva.clm.wrapResult("getApprovedDocument", callback, result);
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
1032
|
+
|
|
1033
|
+
},
|
|
1034
|
+
// Launches the Send Email user interface with the email template and fragments selected. An Account must be selected.
|
|
1035
|
+
// If CLM_Select_Account_Preview_Mode Veeva Setting is enabled, then Select Account dialogue is opened so the user can select an account.
|
|
1036
|
+
// If the Veeva Setting is not enabled and no Account is selected, then no action will be performed.
|
|
1037
|
+
// email_template - specifies the record ID of the Email Template to use
|
|
1038
|
+
// email_fragments - array or string with comma separated values of record IDs of the Email fragments to use. Can be made optional by putting in ""
|
|
1039
|
+
// callback - call back function which will be used to return the information
|
|
1040
|
+
launchApprovedEmail: function(email_template, email_fragments, callback) {
|
|
1041
|
+
// check parameter
|
|
1042
|
+
|
|
1043
|
+
ret = this.checkCallbackFunction(callback);
|
|
1044
|
+
if(ret.success == false)
|
|
1045
|
+
return ret;
|
|
1046
|
+
|
|
1047
|
+
// check arguments and make them empty if they don't exist
|
|
1048
|
+
if(email_template == undefined || email_template == null) {
|
|
1049
|
+
email_template = "";
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
//Make sure email_fragments exists
|
|
1053
|
+
if(email_fragments == undefined || email_fragments == null) {
|
|
1054
|
+
email_fragments = "";
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
request = null;
|
|
1058
|
+
window["com_veeva_clm_launchApprovedEmail"] = function(result) {
|
|
1059
|
+
result = com.veeva.clm.formatResult(result);
|
|
1060
|
+
if(result.success) {
|
|
1061
|
+
ret = {};
|
|
1062
|
+
ret.success = true;
|
|
1063
|
+
if(result.code != undefined) {
|
|
1064
|
+
ret.code = result.code;
|
|
1065
|
+
ret.message = result.message;
|
|
1066
|
+
}
|
|
1067
|
+
com.veeva.clm.wrapResult("launchApprovedEmail", callback, ret);
|
|
1068
|
+
} else {
|
|
1069
|
+
ret = {};
|
|
1070
|
+
ret.success = false;
|
|
1071
|
+
ret.code = result.code;
|
|
1072
|
+
ret.message = "Request: " + request + " failed: " + result.message;
|
|
1073
|
+
com.veeva.clm.wrapResult("launchApprovedEmail", callback, ret);
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
request = "veeva:launchApprovedEmail(" + email_template + "," + email_fragments + "),callback(com_veeva_clm_launchApprovedEmail)";
|
|
1078
|
+
|
|
1079
|
+
if(!com.veeva.clm.testMode)
|
|
1080
|
+
com.veeva.clm.runAPIRequest(request);
|
|
1081
|
+
else
|
|
1082
|
+
com_veeva_clm_launchApprovedEmail(com.veeva.clm.testResult.approvedEmailId);
|
|
1083
|
+
|
|
1084
|
+
},
|
|
1085
|
+
|
|
1086
|
+
// Launches the Send Email user interface with the email template and fragments selected with a veeva content. An Account must be selected.
|
|
1087
|
+
// If CLM_Select_Account_Preview_Mode Veeva Setting is enabled, then Select Account dialogue is opened so the user can select an account.
|
|
1088
|
+
// If the Veeva Setting is not enabled and no Account is selected, then no action will be performed.
|
|
1089
|
+
// email_template - specifies the record ID of the Email Template to use
|
|
1090
|
+
// email_fragments - array or string with comma separated values of record IDs of the Email fragments to use. Can be made optional by putting in ""
|
|
1091
|
+
// veeva_content - specifies the record ID of the Veeva Content
|
|
1092
|
+
// callback - call back function which will be used to return the information
|
|
1093
|
+
//
|
|
1094
|
+
launchApprovedEmailWithVeevaContent: function(email_template, email_fragments, veeva_content, callback) {
|
|
1095
|
+
// check parameters
|
|
1096
|
+
ret = this.checkCallbackFunction(callback);
|
|
1097
|
+
if(ret.success == false) {
|
|
1098
|
+
return ret;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
ret = this.checkArgument("veeva_content", veeva_content);
|
|
1102
|
+
if(ret.success == false) {
|
|
1103
|
+
com.veeva.clm.wrapResult("launchApprovedEmailWithVeevaContent", callback, ret);
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// check arguments and make them empty if they don't exist
|
|
1108
|
+
if(email_template == undefined || email_template == null) {
|
|
1109
|
+
email_template = "";
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
//Make sure email_fragments exists
|
|
1113
|
+
if(email_fragments == undefined || email_fragments == null) {
|
|
1114
|
+
email_fragments = "";
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
veev_content_element = ""
|
|
1118
|
+
if(veeva_content && veeva_content.trim() !== "") {
|
|
1119
|
+
veev_content_element = ",contentId(" + veeva_content + ")"
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
window["com_veeva_clm_launchApprovedEmailWithVeevaContent"] = function(result) {
|
|
1123
|
+
ret = com.veeva.clm.formatResult(result);
|
|
1124
|
+
com.veeva.clm.wrapResult("launchApprovedEmailWithVeevaContent", callback, ret);
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
request = "veeva:launchApprovedEmail(" + email_template + "," + email_fragments + ")" + veev_content_element + ",callback(com_veeva_clm_launchApprovedEmailWithVeevaContent)";
|
|
1128
|
+
|
|
1129
|
+
if(!com.veeva.clm.testMode) {
|
|
1130
|
+
com.veeva.clm.runAPIRequest(request);
|
|
1131
|
+
} else {
|
|
1132
|
+
com_veeva_clm_launchApprovedEmailWithVeevaContent(com.veeva.clm.testResult.common);
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
},
|
|
1136
|
+
|
|
1137
|
+
/////////////////////// Functions to replace exising API calls ///////////////////////
|
|
1138
|
+
|
|
1139
|
+
// 1
|
|
1140
|
+
// Returns the value of a field for a specific record related to the current call
|
|
1141
|
+
// object - Limited to the following keywords: Account, TSF, User, Address, Call, Presentation, KeyMessage, and CallObjective.
|
|
1142
|
+
// field- field api name to return a value for
|
|
1143
|
+
// callback - call back function which will be used to return the information
|
|
1144
|
+
getDataForCurrentObject: function(object, field, callback) {
|
|
1145
|
+
ret = this.checkCallbackFunction(callback);
|
|
1146
|
+
if(ret.success == false)
|
|
1147
|
+
return ret;
|
|
1148
|
+
|
|
1149
|
+
// check arguments
|
|
1150
|
+
ret = this.checkArgument("object", object);
|
|
1151
|
+
if(ret.success == false) {
|
|
1152
|
+
com.veeva.clm.wrapResult("getDataForCurrentObject", callback, ret);
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
ret = this.checkArgument("field", field);
|
|
1158
|
+
if(ret.success == false) {
|
|
1159
|
+
com.veeva.clm.wrapResult("getDataForCurrentObject", callback, ret);
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
window["com_veeva_clm_getCurrentObjectField"] = function(result) {
|
|
1164
|
+
// TODO result format
|
|
1165
|
+
com.veeva.clm.wrapResult("getDataForCurrentObject", callback, result);
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
lowerName = object.toLowerCase();
|
|
1169
|
+
|
|
1170
|
+
request = "veeva:getDataForObjectV2(" + object + "),fieldName(" + field + "),com_veeva_clm_getCurrentObjectField(result)";
|
|
1171
|
+
if(!com.veeva.clm.testMode)
|
|
1172
|
+
com.veeva.clm.runAPIRequest(request, callback);
|
|
1173
|
+
else
|
|
1174
|
+
com_veeva_clm_getCurrentObjectField(com.veeva.clm.testResult.common);
|
|
1175
|
+
},
|
|
1176
|
+
|
|
1177
|
+
// 2
|
|
1178
|
+
// Returns the value of a field for a specific record
|
|
1179
|
+
// object - specifies the object api name (object keywords used in getDataForCurrentObject are not valid, except for Account and User)
|
|
1180
|
+
// record - specifies the record id.
|
|
1181
|
+
// field- field api name to return a value for
|
|
1182
|
+
// callback - call back function which will be used to return the information
|
|
1183
|
+
getDataForObject: function(object, record, field, callback) {
|
|
1184
|
+
ret = this.checkCallbackFunction(callback);
|
|
1185
|
+
if(ret.success == false)
|
|
1186
|
+
return ret;
|
|
1187
|
+
|
|
1188
|
+
// check arguments
|
|
1189
|
+
ret = this.checkArgument("object", object);
|
|
1190
|
+
if(ret.success == false) {
|
|
1191
|
+
com.veeva.clm.wrapResult("getDataForObject", callback, ret);
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
ret = this.checkArgument("record", record);
|
|
1197
|
+
if(ret.success == false) {
|
|
1198
|
+
com.veeva.clm.wrapResult("getDataForObject", callback, ret);
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
ret = this.checkArgument("field", field);
|
|
1203
|
+
if(ret.success == false) {
|
|
1204
|
+
com.veeva.clm.wrapResult("getDataForObject", callback, ret);
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
window["com_veeva_clm_getObjectField"] = function(result) {
|
|
1209
|
+
// TODO result format
|
|
1210
|
+
com.veeva.clm.wrapResult("getDataForObject", callback, result);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
request = "veeva:getDataForObjectV2(" + object + "),objId(" + record + "),fieldName(" + field + "),com_veeva_clm_getObjectField(result)";
|
|
1215
|
+
if(!com.veeva.clm.testMode)
|
|
1216
|
+
com.veeva.clm.runAPIRequest(request, callback);
|
|
1217
|
+
else
|
|
1218
|
+
com_veeva_clm_getObjectField(com.veeva.clm.testResult.common);
|
|
1219
|
+
|
|
1220
|
+
},
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
// 3
|
|
1224
|
+
// Creates a new record for the specified object
|
|
1225
|
+
// object - specifies the object api name
|
|
1226
|
+
// values - json object with the fields and values to be written to the new record
|
|
1227
|
+
// callback - call back function which will be used to return the information
|
|
1228
|
+
// NOTE: This function returns success: true as long as the user has access to the object.
|
|
1229
|
+
// If the user does not have access to one of the fields specified, success: true is still returned, however,
|
|
1230
|
+
// and the fields the user does have access to are still updated.
|
|
1231
|
+
createRecord: function(object, values, callback) {
|
|
1232
|
+
ret = this.checkCallbackFunction(callback);
|
|
1233
|
+
if(ret.success == false)
|
|
1234
|
+
return ret;
|
|
1235
|
+
|
|
1236
|
+
// check arguments
|
|
1237
|
+
ret = this.checkArgument("object", object);
|
|
1238
|
+
if(ret.success == false) {
|
|
1239
|
+
com.veeva.clm.wrapResult("createRecord", callback, ret);
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
ret = this.checkArgument("values", values);
|
|
1245
|
+
if(ret.success == false) {
|
|
1246
|
+
com.veeva.clm.wrapResult("createRecord", callback, ret);
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
request = com.veeva.clm.generateSaveRecordRequest(object, values, "com_veeva_clm_createRecord");
|
|
1251
|
+
window["com_veeva_clm_createRecord"] = function(result) {
|
|
1252
|
+
result = com.veeva.clm.formatResult(result);
|
|
1253
|
+
if(result.success) {
|
|
1254
|
+
ret = {};
|
|
1255
|
+
ret.success = true;
|
|
1256
|
+
ret.operation = result.operation;
|
|
1257
|
+
ret[object] = {};
|
|
1258
|
+
ret[object].ID = result.objectId;
|
|
1259
|
+
if(result.code != undefined) {
|
|
1260
|
+
ret.code = result.code;
|
|
1261
|
+
ret.message = result.message;
|
|
1262
|
+
}
|
|
1263
|
+
com.veeva.clm.wrapResult("createRecord", callback, ret);
|
|
1264
|
+
} else {
|
|
1265
|
+
ret = {};
|
|
1266
|
+
ret.success = false;
|
|
1267
|
+
ret.code = 2100;
|
|
1268
|
+
ret.message = "Request: " + request + " failed: " + result.message;
|
|
1269
|
+
com.veeva.clm.wrapResult("createRecord", callback, ret);
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
|
|
1273
|
+
// create record
|
|
1274
|
+
if(!com.veeva.clm.testMode)
|
|
1275
|
+
com.veeva.clm.runAPIRequest(request);
|
|
1276
|
+
else
|
|
1277
|
+
com_veeva_clm_createRecord(com.veeva.clm.testResult.common);
|
|
1278
|
+
},
|
|
1279
|
+
|
|
1280
|
+
// 4
|
|
1281
|
+
// Updates a specified record
|
|
1282
|
+
// object - specifies the object api name
|
|
1283
|
+
// record - specifies the record id to be updated
|
|
1284
|
+
// values - json object with the fields and values updated on the record
|
|
1285
|
+
// callback - call back function which will be used to return the information
|
|
1286
|
+
// NOTE: This function returns success: true as long as the user has access to the object.
|
|
1287
|
+
// If the user does not have access to one of the fields specified, success: true is still returned, however,
|
|
1288
|
+
// and the fields the user does have access to are still updated.
|
|
1289
|
+
updateRecord: function(object, record, values, callback) {
|
|
1290
|
+
ret = this.checkCallbackFunction(callback);
|
|
1291
|
+
if(ret.success == false)
|
|
1292
|
+
return ret;
|
|
1293
|
+
|
|
1294
|
+
// check arguments
|
|
1295
|
+
ret = this.checkArgument("object", object);
|
|
1296
|
+
if(ret.success == false) {
|
|
1297
|
+
com.veeva.clm.wrapResult("updateRecord", callback, ret);
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
ret = this.checkArgument("record", record);
|
|
1302
|
+
if(ret.success == false) {
|
|
1303
|
+
com.veeva.clm.wrapResult("updateRecord", callback, ret);
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
ret = this.checkArgument("values", values);
|
|
1308
|
+
if(ret.success == false) {
|
|
1309
|
+
com.veeva.clm.wrapResult("updateRecord", callback, ret);
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
// Id is required for updating existing record
|
|
1313
|
+
values.IdNumber = record;
|
|
1314
|
+
|
|
1315
|
+
// create record
|
|
1316
|
+
request = com.veeva.clm.generateSaveRecordRequest(object, values, "com_veeva_clm_updateRecord");
|
|
1317
|
+
|
|
1318
|
+
window["com_veeva_clm_updateRecord"] = function(result) {
|
|
1319
|
+
result = com.veeva.clm.formatResult(result);
|
|
1320
|
+
if(result.success) {
|
|
1321
|
+
ret = {};
|
|
1322
|
+
ret.success = true;
|
|
1323
|
+
ret.operation = result.operation;
|
|
1324
|
+
ret[object] = {};
|
|
1325
|
+
ret[object].ID = result.objectId;
|
|
1326
|
+
if(result.code != undefined) {
|
|
1327
|
+
ret.code = result.code;
|
|
1328
|
+
ret.message = result.message;
|
|
1329
|
+
}
|
|
1330
|
+
com.veeva.clm.wrapResult("updateRecord", callback, ret);
|
|
1331
|
+
} else {
|
|
1332
|
+
ret = {};
|
|
1333
|
+
ret.success = false;
|
|
1334
|
+
ret.code = 2100;
|
|
1335
|
+
ret.message = "Request: " + request + " failed: " + result.message;
|
|
1336
|
+
com.veeva.clm.wrapResult("updateRecord", callback, ret);
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
if(!com.veeva.clm.testMode)
|
|
1341
|
+
com.veeva.clm.runAPIRequest(request);
|
|
1342
|
+
else
|
|
1343
|
+
com_veeva_clm_updateRecord(com.veeva.clm.testResult.common);
|
|
1344
|
+
},
|
|
1345
|
+
|
|
1346
|
+
// 5a
|
|
1347
|
+
// Navigates to the specified key message (Key_Message_vod__c)
|
|
1348
|
+
// key message - external ID field of the key message to jump to. Usually is Media_File_Name_vod__c, but does not have to be.
|
|
1349
|
+
// clm presentation - external ID of the CLM Presentation if the key message is in a different CLM Presentation.
|
|
1350
|
+
// Usually is Presentation_Id_vod__c, but does not have to be. Can be made optional by putting in "".
|
|
1351
|
+
gotoSlide: function(keyMessage, presentation) {
|
|
1352
|
+
|
|
1353
|
+
ret = this.checkArgument("keyMessage", keyMessage);
|
|
1354
|
+
if(ret.success == false) {
|
|
1355
|
+
return ret;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
request = null;
|
|
1359
|
+
if(presentation == undefined || presentation == null || presentation == "") {
|
|
1360
|
+
// goto within current presenation
|
|
1361
|
+
request = "veeva:gotoSlide(" + keyMessage + ")";
|
|
1362
|
+
} else {
|
|
1363
|
+
request = "veeva:gotoSlide(" + keyMessage + "," + presentation + ")";
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
if(!com.veeva.clm.testMode)
|
|
1367
|
+
com.veeva.clm.runAPIRequest(request);
|
|
1368
|
+
|
|
1369
|
+
},
|
|
1370
|
+
|
|
1371
|
+
// 5b
|
|
1372
|
+
// Navigates to the specified key message (Key_Message_vod__c)
|
|
1373
|
+
// key message - Vault_External_Id_vod__c field of the key message to jump to
|
|
1374
|
+
// clm presentation - Vault_External_Id_vod__c of the CLM Presentation if the key message is in a different CLM Presentation.
|
|
1375
|
+
// Can be made optional by putting in "".
|
|
1376
|
+
gotoSlideV2: function(keyMessage, presentation) {
|
|
1377
|
+
|
|
1378
|
+
ret = this.checkArgument("keyMessage", keyMessage);
|
|
1379
|
+
if(ret.success == false) {
|
|
1380
|
+
return ret;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
request = null;
|
|
1384
|
+
if(presentation == undefined || presentation == null || presentation == "") {
|
|
1385
|
+
// goto within current presentation
|
|
1386
|
+
request = "veeva:gotoSlideV2(" + keyMessage + ")";
|
|
1387
|
+
} else {
|
|
1388
|
+
request = "veeva:gotoSlideV2(" + keyMessage + "," + presentation + ")";
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
if(!com.veeva.clm.testMode)
|
|
1392
|
+
com.veeva.clm.runAPIRequest(request);
|
|
1393
|
+
|
|
1394
|
+
},
|
|
1395
|
+
|
|
1396
|
+
// 6
|
|
1397
|
+
// Navigates to the next slide based on the CLM Presentation Slide display order
|
|
1398
|
+
nextSlide: function() {
|
|
1399
|
+
request = "veeva:nextSlide()";
|
|
1400
|
+
com.veeva.clm.runAPIRequest(request);
|
|
1401
|
+
},
|
|
1402
|
+
|
|
1403
|
+
// 7
|
|
1404
|
+
// Navigates to the previous slide based on the CLM Presentation Slide display order
|
|
1405
|
+
prevSlide: function() {
|
|
1406
|
+
request = "veeva:prevSlide()";
|
|
1407
|
+
com.veeva.clm.runAPIRequest(request);
|
|
1408
|
+
},
|
|
1409
|
+
|
|
1410
|
+
// 8
|
|
1411
|
+
// Returns the value of the field in UTC format. Only works with field of type Date or Datetime.
|
|
1412
|
+
// object - specifies the object api name (object keywords used in getDataForCurrentObject are not valid, except for Account)
|
|
1413
|
+
// record - specifies the record id.
|
|
1414
|
+
// field- field api name to return a value for
|
|
1415
|
+
// callback - call back function which will be used to return the information
|
|
1416
|
+
getUTCdatetime: function(object, record, field, callback) {
|
|
1417
|
+
ret = this.checkCallbackFunction(callback);
|
|
1418
|
+
if(ret.success == false)
|
|
1419
|
+
return ret;
|
|
1420
|
+
|
|
1421
|
+
// check arguments
|
|
1422
|
+
ret = this.checkArgument("object", object);
|
|
1423
|
+
if(ret.success == false) {
|
|
1424
|
+
com.veeva.clm.wrapResult("getUTCdatetime", callback, ret);
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
ret = this.checkArgument("record", record);
|
|
1430
|
+
if(ret.success == false) {
|
|
1431
|
+
com.veeva.clm.wrapResult("getUTCdatetime", callback, ret);
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
ret = this.checkArgument("field", field);
|
|
1436
|
+
if(ret.success == false) {
|
|
1437
|
+
com.veeva.clm.wrapResult("getUTCdatetime", callback, ret);
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
window["com_veeva_clm_getUTCdatetime"] = function(result) {
|
|
1442
|
+
// TODO result format
|
|
1443
|
+
com.veeva.clm.wrapResult("getUTCdatetime", callback, result);
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
request = "veeva:getDataForObjectV3(" + object + "),objId(" + record + "),fieldName(" + field + "),getUTCdatetime(true),callback(com_veeva_clm_getUTCdatetime)";
|
|
1448
|
+
if(!com.veeva.clm.testMode)
|
|
1449
|
+
com.veeva.clm.runAPIRequest(request, callback);
|
|
1450
|
+
else
|
|
1451
|
+
com_veeva_clm_getUTCdatetime(com.veeva.clm.testResult.common);
|
|
1452
|
+
|
|
1453
|
+
},
|
|
1454
|
+
|
|
1455
|
+
// 9,
|
|
1456
|
+
// Updates the current record related to the call
|
|
1457
|
+
// object - specifies the object api name
|
|
1458
|
+
// values - json object with the fields and values updated on the record (ignores id field if specified)
|
|
1459
|
+
// callback - call back function which will be used to return the information
|
|
1460
|
+
// Uses saveObjectV2 call
|
|
1461
|
+
// Note: This function returns success: true as long as the user has access to the object and record specified.
|
|
1462
|
+
// If the user does not have access to one of the fields specified, success: true is still returned and the fields the user does have access to are updated.
|
|
1463
|
+
// If there are fields which are not accessible, code 0200 is returned and the message specifies the field names.
|
|
1464
|
+
// If there is no current record (user is in Media Preview), the function is temporarily saved and executed when an Account is selected.
|
|
1465
|
+
// If no Account is selected, the function is discarded on exit of Media Preview. The callback function will not be executed if there is no current record.
|
|
1466
|
+
updateCurrentRecord: function(object, values, callback) {
|
|
1467
|
+
ret = this.checkCallbackFunction(callback);
|
|
1468
|
+
if(ret.success == false)
|
|
1469
|
+
return ret;
|
|
1470
|
+
|
|
1471
|
+
// check arguments
|
|
1472
|
+
ret = this.checkArgument("object", object);
|
|
1473
|
+
if(ret.success == false) {
|
|
1474
|
+
com.veeva.clm.wrapResult("updateCurrentRecord", callback, ret);
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
ret = this.checkArgument("values", values);
|
|
1479
|
+
if(ret.success == false) {
|
|
1480
|
+
com.veeva.clm.wrapResult("updateCurrentRecord", callback, ret);
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
// create record
|
|
1485
|
+
request = "veeva:saveObjectV2(" + object + "),updateCurrentRecord(),value(" + JSON.stringify(values) + "),callback(com_veeva_clm_updateCurrentRecord)";
|
|
1486
|
+
|
|
1487
|
+
window["com_veeva_clm_updateCurrentRecord"] = function(result) {
|
|
1488
|
+
result = com.veeva.clm.formatResult(result);
|
|
1489
|
+
if(result.success) {
|
|
1490
|
+
ret = {};
|
|
1491
|
+
ret.success = true;
|
|
1492
|
+
ret[object] = {};
|
|
1493
|
+
ret[object].ID = result.objectId;
|
|
1494
|
+
if(result.code != undefined) {
|
|
1495
|
+
ret.code = result.code;
|
|
1496
|
+
ret.message = result.message;
|
|
1497
|
+
}
|
|
1498
|
+
com.veeva.clm.wrapResult("updateCurrentRecord", callback, ret);
|
|
1499
|
+
} else {
|
|
1500
|
+
ret = {};
|
|
1501
|
+
ret.success = false;
|
|
1502
|
+
ret.code = 2100;
|
|
1503
|
+
ret.message = "Request: " + request + " failed: " + result.message;
|
|
1504
|
+
com.veeva.clm.wrapResult("updateCurrentRecord", callback, ret);
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1507
|
+
|
|
1508
|
+
if(!com.veeva.clm.testMode)
|
|
1509
|
+
com.veeva.clm.runAPIRequest(request);
|
|
1510
|
+
else
|
|
1511
|
+
com_veeva_clm_updateCurrentRecord(com.veeva.clm.testResult.common);
|
|
1512
|
+
},
|
|
1513
|
+
|
|
1514
|
+
// 10,
|
|
1515
|
+
// Formats a string for createRecordsOnExit() and returns it
|
|
1516
|
+
formatCreateRecords:function(objectArray, valueArray) {
|
|
1517
|
+
//check arguments
|
|
1518
|
+
ret = this.checkArgument("objectArray", objectArray);
|
|
1519
|
+
if(ret.success == false){
|
|
1520
|
+
return ret;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
ret = this.checkArgument("valueArray", valueArray);
|
|
1524
|
+
if(ret.success == false){
|
|
1525
|
+
return ret;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
if (!(objectArray instanceof Array)) {
|
|
1529
|
+
objectArray = [objectArray];
|
|
1530
|
+
}
|
|
1531
|
+
if (!(valueArray instanceof Array)) {
|
|
1532
|
+
valueArray = [valueArray];
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
//If the number of objects doesn't match the number of values, return
|
|
1536
|
+
ret = {};
|
|
1537
|
+
if (objectArray.length != valueArray.length) {
|
|
1538
|
+
ret.success = false;
|
|
1539
|
+
ret.code = 2003;
|
|
1540
|
+
ret.message = "Parameter arrays must be of equal length";
|
|
1541
|
+
return ret;
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
//Make the concatenation of all saveObjectV2 requests we need to make
|
|
1545
|
+
var fullString = "";
|
|
1546
|
+
for (var ndx = 0; ndx < objectArray.length; ndx++) {
|
|
1547
|
+
fullString = fullString.concat(com.veeva.clm.generateSaveRecordRequest(objectArray[ndx], valueArray[ndx], "") + ";");
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
return fullString;
|
|
1551
|
+
},
|
|
1552
|
+
|
|
1553
|
+
// 11,
|
|
1554
|
+
// Formats a string for updateRecordsOnExit() and returns it
|
|
1555
|
+
formatUpdateRecords:function(objectNameArray, objectIdArray, valueArray) {
|
|
1556
|
+
//check arguments
|
|
1557
|
+
ret = this.checkArgument("objectNameArray", objectNameArray);
|
|
1558
|
+
if(ret.success == false){
|
|
1559
|
+
return ret;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
ret = this.checkArgument("objectIdArray", objectIdArray);
|
|
1563
|
+
if(ret.success == false){
|
|
1564
|
+
return ret;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
ret = this.checkArgument("valueArray", valueArray);
|
|
1568
|
+
if(ret.success == false){
|
|
1569
|
+
return ret;
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
if (!(objectNameArray instanceof Array)) {
|
|
1573
|
+
objectNameArray = [objectNameArray];
|
|
1574
|
+
}
|
|
1575
|
+
if (!(objectIdArray instanceof Array)) {
|
|
1576
|
+
objectIdArray = [objectIdArray];
|
|
1577
|
+
}
|
|
1578
|
+
if (!(valueArray instanceof Array)) {
|
|
1579
|
+
valueArray = [valueArray];
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
//If the number of objects doesn't match the number of values, return
|
|
1583
|
+
ret = {};
|
|
1584
|
+
if (objectNameArray.length != valueArray.length || objectNameArray.length != objectIdArray.length) {
|
|
1585
|
+
ret.success = false;
|
|
1586
|
+
ret.code = 2003;
|
|
1587
|
+
ret.message = "Parameter arrays must be of equal length";
|
|
1588
|
+
return ret;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
//Make the concatenation of all saveObjectV2 requests we need to make
|
|
1592
|
+
var fullString = "";
|
|
1593
|
+
for (var ndx = 0; ndx < objectNameArray.length; ndx++) {
|
|
1594
|
+
//Set IdNumber in value array
|
|
1595
|
+
valueArray[ndx].IdNumber = objectIdArray[ndx];
|
|
1596
|
+
|
|
1597
|
+
//concat string together
|
|
1598
|
+
fullString = fullString.concat(com.veeva.clm.generateSaveRecordRequest(objectNameArray[ndx], valueArray[ndx], "") + ";");
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
return fullString;
|
|
1602
|
+
},
|
|
1603
|
+
|
|
1604
|
+
// 12,
|
|
1605
|
+
// Creates a string as if it was a request for updateCurrentRecord and returns it
|
|
1606
|
+
formatUpdateCurrentRecords:function(objectArray, valueArray) {
|
|
1607
|
+
//check arguments
|
|
1608
|
+
ret = this.checkArgument("objectArray", objectArray);
|
|
1609
|
+
if(ret.success == false){
|
|
1610
|
+
com.veeva.clm.wrapResult("formatUpdateCurrentRecord", callback, ret);
|
|
1611
|
+
return ret;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
ret = this.checkArgument("valueArray", valueArray);
|
|
1615
|
+
if(ret.success == false){
|
|
1616
|
+
com.veeva.clm.wrapResult("formatUpdateCurrentRecord", callback, ret);
|
|
1617
|
+
return ret;
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
if (!(objectArray instanceof Array)) {
|
|
1621
|
+
objectArray = [objectArray];
|
|
1622
|
+
}
|
|
1623
|
+
if (!(valueArray instanceof Array)) {
|
|
1624
|
+
valueArray = [valueArray];
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
//If the number of objects doesn't match the number of values, return
|
|
1628
|
+
ret = {};
|
|
1629
|
+
if (objectArray.length != valueArray.length) {
|
|
1630
|
+
ret.success = false;
|
|
1631
|
+
ret.code = 2003;
|
|
1632
|
+
ret.message = "Parameter arrays must be of equal length";
|
|
1633
|
+
return ret;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
//Make the concatenation of all saveObjectV2 requests we need to make
|
|
1637
|
+
var fullString = "";
|
|
1638
|
+
for (var ndx = 0; ndx < objectArray.length; ndx++) {
|
|
1639
|
+
fullString = fullString.concat("veeva:saveObjectV2(" + objectArray[ndx] + "),updateCurrentRecord(),value(" + JSON.stringify(valueArray[ndx]) + "),callback()" + ";");
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
return fullString;
|
|
1643
|
+
},
|
|
1644
|
+
|
|
1645
|
+
//13,
|
|
1646
|
+
// Formats a createRecord or updateRecord request in the proper form
|
|
1647
|
+
generateSaveRecordRequest:function(object, values, callback){
|
|
1648
|
+
return "veeva:saveObjectV2(" + object + "),value(" + JSON.stringify(values) + "),callback(" + callback + ")";
|
|
1649
|
+
},
|
|
1650
|
+
|
|
1651
|
+
//14,
|
|
1652
|
+
// Queries for and returns the specified fields for all records which match the where clause.
|
|
1653
|
+
// Also returns count of records returned.
|
|
1654
|
+
//
|
|
1655
|
+
// object - The API Name of the object that you want to query
|
|
1656
|
+
// fields - Comma delimited string of field API names
|
|
1657
|
+
//
|
|
1658
|
+
// Optional fields:
|
|
1659
|
+
// where - string for the where clause (See documentation for supported clauses).
|
|
1660
|
+
// sort - Array of strings which represents the sort, example: ["Name_vod__c, DESC", "Status_vod__c, ASC"]
|
|
1661
|
+
// limit - the maximum number of records to return
|
|
1662
|
+
queryRecord:function(object, fields, where, sort, limit, callback){
|
|
1663
|
+
ret = this.checkCallbackFunction(callback);
|
|
1664
|
+
if(ret.success == false)
|
|
1665
|
+
return ret;
|
|
1666
|
+
|
|
1667
|
+
// check arguments
|
|
1668
|
+
ret = this.checkArgument("object", object);
|
|
1669
|
+
if(ret.success == false) {
|
|
1670
|
+
com.veeva.clm.wrapResult("queryRecord", callback, ret);
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
ret = this.checkArgument("fields", fields);
|
|
1675
|
+
if(ret.success == false) {
|
|
1676
|
+
com.veeva.clm.wrapResult("queryRecord", callback, ret);
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
//Don't check the Where, limit, or sort clauses because they can be null and thats acceptable.
|
|
1681
|
+
|
|
1682
|
+
window["com_veeva_clm_queryRecordReturn"] = function(result) {
|
|
1683
|
+
result = com.veeva.clm.formatResult(result);
|
|
1684
|
+
com.veeva.clm.wrapResult("queryRecord", callback, result);
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
request = "veeva:queryObject(" + object + "),fields(" + fields + "),";
|
|
1689
|
+
if (where != null && where != undefined) {
|
|
1690
|
+
request = request + "where(" + where + "),";
|
|
1691
|
+
}
|
|
1692
|
+
if (sort != null && sort != undefined) {
|
|
1693
|
+
request = request + "sort(" + JSON.stringify(sort) + "),";
|
|
1694
|
+
}
|
|
1695
|
+
if (limit != null && limit != undefined) {
|
|
1696
|
+
request = request + "limit(" + limit + "),";
|
|
1697
|
+
}
|
|
1698
|
+
request = request + "com_veeva_clm_queryRecordReturn(result)";
|
|
1699
|
+
|
|
1700
|
+
com.veeva.clm.runAPIRequest(request, callback);
|
|
1701
|
+
},
|
|
1702
|
+
|
|
1703
|
+
//15,
|
|
1704
|
+
// Returns the translated label for each of the specified fields
|
|
1705
|
+
//
|
|
1706
|
+
// object - API Name of the object
|
|
1707
|
+
// fields - Array of Field API Names
|
|
1708
|
+
getFieldLabel:function(object, fields, callback){
|
|
1709
|
+
ret = this.checkCallbackFunction(callback);
|
|
1710
|
+
if(ret.success == false)
|
|
1711
|
+
return ret;
|
|
1712
|
+
|
|
1713
|
+
// check arguments
|
|
1714
|
+
ret = this.checkArgument("object", object);
|
|
1715
|
+
if(ret.success == false) {
|
|
1716
|
+
com.veeva.clm.wrapResult("getFieldLabel", callback, ret);
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
ret = this.checkArgument("fields", fields);
|
|
1721
|
+
if(ret.success == false) {
|
|
1722
|
+
com.veeva.clm.wrapResult("getFieldLabel", callback, ret);
|
|
1723
|
+
return;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
window["com_veeva_clm_getFieldLabelReturn"] = function(result) {
|
|
1727
|
+
result = com.veeva.clm.formatResult(result);
|
|
1728
|
+
com.veeva.clm.wrapResult("getFieldLabel", callback, result);
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
request = "veeva:getFieldLabel(" + object + "),fields(" + JSON.stringify(fields) + "), com_veeva_clm_getFieldLabelReturn(result)";
|
|
1733
|
+
com.veeva.clm.runAPIRequest(request, callback);
|
|
1734
|
+
},
|
|
1735
|
+
|
|
1736
|
+
//16,
|
|
1737
|
+
// Returns each record type api name and record type translated label
|
|
1738
|
+
//
|
|
1739
|
+
// object - API Name of the object to get all record types for
|
|
1740
|
+
getRecordTypeLabels:function(object, callback){
|
|
1741
|
+
ret = this.checkCallbackFunction(callback);
|
|
1742
|
+
if(ret.success == false)
|
|
1743
|
+
return ret;
|
|
1744
|
+
|
|
1745
|
+
// check arguments
|
|
1746
|
+
ret = this.checkArgument("object", object);
|
|
1747
|
+
if(ret.success == false) {
|
|
1748
|
+
com.veeva.clm.wrapResult("getRecordTypeLabels", callback, ret);
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
window["com_veeva_clm_getRecordTypeLabelsReturn"] = function(result) {
|
|
1753
|
+
result = com.veeva.clm.formatResult(result);
|
|
1754
|
+
com.veeva.clm.wrapResult("getRecordTypeLabels", callback, result);
|
|
1755
|
+
return;
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
request = "veeva:getRecordTypeLabels(" + object + "),com_veeva_clm_getRecordTypeLabelsReturn(result)";
|
|
1759
|
+
com.veeva.clm.runAPIRequest(request, callback);
|
|
1760
|
+
},
|
|
1761
|
+
|
|
1762
|
+
//17,
|
|
1763
|
+
// Returns the translated label for each of the picklist values of the specified field
|
|
1764
|
+
//
|
|
1765
|
+
// object - API Name of the object
|
|
1766
|
+
// field - API Name of the picklist field
|
|
1767
|
+
getPicklistValueLabels:function(object, field, callback){
|
|
1768
|
+
ret = this.checkCallbackFunction(callback);
|
|
1769
|
+
if(ret.success == false)
|
|
1770
|
+
return ret;
|
|
1771
|
+
|
|
1772
|
+
// check arguments
|
|
1773
|
+
ret = this.checkArgument("object", object);
|
|
1774
|
+
if(ret.success == false) {
|
|
1775
|
+
com.veeva.clm.wrapResult("getPicklistValueLabels", callback, ret);
|
|
1776
|
+
return;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
ret = this.checkArgument("field", field);
|
|
1780
|
+
if(ret.success == false) {
|
|
1781
|
+
com.veeva.clm.wrapResult("getPicklistValueLabels", callback, ret);
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
window["com_veeva_clm_getPicklistValueLabelsReturn"] = function(result) {
|
|
1786
|
+
result = com.veeva.clm.formatResult(result);
|
|
1787
|
+
com.veeva.clm.wrapResult("getPicklistValueLabels", callback, result);
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
request = "veeva:getPicklistValueLabels(" + object + "),field(" + field + "), com_veeva_clm_getPicklistValueLabelsReturn(result)";
|
|
1792
|
+
com.veeva.clm.runAPIRequest(request, callback);
|
|
1793
|
+
},
|
|
1794
|
+
|
|
1795
|
+
//18,
|
|
1796
|
+
// Returns object translated labels array for each object API name
|
|
1797
|
+
// objects - array of object API Names to get translated labels for
|
|
1798
|
+
getObjectLabels:function(objects, callback){
|
|
1799
|
+
var ret = this.checkCallbackFunction(callback);
|
|
1800
|
+
if(ret.success == false)
|
|
1801
|
+
return ret;
|
|
1802
|
+
|
|
1803
|
+
// check arguments
|
|
1804
|
+
ret = this.checkArgument("objects", objects);
|
|
1805
|
+
if(ret.success == false) {
|
|
1806
|
+
com.veeva.clm.wrapResult("getObjectLabels", callback, ret);
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
window["com_veeva_clm_getObjectLabelsReturn"] = function(result) {
|
|
1811
|
+
result = com.veeva.clm.formatResult(result);
|
|
1812
|
+
com.veeva.clm.wrapResult("getObjectLabels", callback, result);
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
request = "veeva:getObjectLabels(" + JSON.stringify(objects) + "),com_veeva_clm_getObjectLabelsReturn(result)";
|
|
1817
|
+
com.veeva.clm.runAPIRequest(request, callback);
|
|
1818
|
+
},
|
|
1819
|
+
|
|
1820
|
+
//19,
|
|
1821
|
+
// Returns HTTP Request result
|
|
1822
|
+
//
|
|
1823
|
+
// object - request object with all HTTP parameters
|
|
1824
|
+
request:function(object, callback){
|
|
1825
|
+
ret = this.checkCallbackFunction(callback);
|
|
1826
|
+
if(!ret.success) {
|
|
1827
|
+
return ret;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
//check request object validity
|
|
1831
|
+
var errorMessage = this.validateRequestObjectWithErrorMessage(object);
|
|
1832
|
+
if (errorMessage !== "Valid") {
|
|
1833
|
+
var error = {
|
|
1834
|
+
success: false,
|
|
1835
|
+
code: 5,
|
|
1836
|
+
message: errorMessage
|
|
1837
|
+
};
|
|
1838
|
+
com.veeva.clm.wrapResult("request", callback, error);
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
this.addRequestObjectDefaultsAndFormat(object);
|
|
1843
|
+
|
|
1844
|
+
window["com_veeva_clm_requestReturn"] = function(result) {
|
|
1845
|
+
result = com.veeva.clm.formatResult(result);
|
|
1846
|
+
com.veeva.clm.wrapResult("request", callback, result);
|
|
1847
|
+
return;
|
|
1848
|
+
};
|
|
1849
|
+
|
|
1850
|
+
var request = "veeva:request(" + JSON.stringify(object) + "),com_veeva_clm_requestReturn(result)";
|
|
1851
|
+
com.veeva.clm.runAPIRequest(request, callback);
|
|
1852
|
+
},
|
|
1853
|
+
|
|
1854
|
+
//20,
|
|
1855
|
+
// Returns the version of the current offline application
|
|
1856
|
+
getAppVersion: function(callback) {
|
|
1857
|
+
ret = this.checkCallbackFunction(callback);
|
|
1858
|
+
if(ret.success == false)
|
|
1859
|
+
return ret;
|
|
1860
|
+
|
|
1861
|
+
window.com_veeva_clm_appVersion = function(result) {
|
|
1862
|
+
clearTimeout(timer);
|
|
1863
|
+
com.veeva.clm.wrapResult("getAppVersion", callback, result);
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
var timer = setTimeout(function() {
|
|
1867
|
+
result = { success: false };
|
|
1868
|
+
com.veeva.clm.wrapResult("getAppVersion", callback, result);
|
|
1869
|
+
}, 1500);
|
|
1870
|
+
|
|
1871
|
+
query = "veeva:getAppVersion(),com_veeva_clm_appVersion(result)";
|
|
1872
|
+
if(!com.veeva.clm.testMode) {
|
|
1873
|
+
com.veeva.clm.runAPIRequest(query);
|
|
1874
|
+
} else {
|
|
1875
|
+
com_veeva_clm_appVersion(com.veeva.clm.testResult.common);
|
|
1876
|
+
}
|
|
1877
|
+
},
|
|
1878
|
+
|
|
1879
|
+
/////////////////////// CLM Specific ///////////////////////
|
|
1880
|
+
//1,
|
|
1881
|
+
// Shows slide selector with specified presentation:key messages; callback gets notified if there aren't any valid key messages
|
|
1882
|
+
// The selector shows presentations in the same order as requested, but slide are in the order as defined in the presentation,
|
|
1883
|
+
// not the order specified in the request.
|
|
1884
|
+
launchSelector: function(presentationSlides, callback) {
|
|
1885
|
+
// check parameter
|
|
1886
|
+
var ret = this.checkCallbackFunction(callback);
|
|
1887
|
+
if(ret.success == false)
|
|
1888
|
+
return ret;
|
|
1889
|
+
|
|
1890
|
+
// check arguments
|
|
1891
|
+
ret = this.checkArgument("presentationSlides", presentationSlides);
|
|
1892
|
+
if(ret.success == false) {
|
|
1893
|
+
com.veeva.clm.wrapResult("presentationSlides", callback, ret);
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
if(presentationSlides.constructor === Array){
|
|
1898
|
+
// check each element for empty presentation id
|
|
1899
|
+
for(var i=0; i < presentationSlides.length; i++){
|
|
1900
|
+
var presentationMessages = presentationSlides[i]
|
|
1901
|
+
if(presentationMessages != null && typeof(presentationMessages) === 'object'){
|
|
1902
|
+
for(var prop in presentationMessages){
|
|
1903
|
+
if(presentationMessages.hasOwnProperty(prop) && prop == ""){
|
|
1904
|
+
// empty presentastion id
|
|
1905
|
+
ret = {};
|
|
1906
|
+
ret.success = false;
|
|
1907
|
+
ret.code = 2002;
|
|
1908
|
+
ret.message = "presentation id is empty";
|
|
1909
|
+
com.veeva.clm.wrapResult("presentationSlides", callback, ret);
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
var request = null;
|
|
1919
|
+
window["com_veeva_clm_launchApprovedEmail"] = function(result) {
|
|
1920
|
+
result = com.veeva.clm.formatResult(result);
|
|
1921
|
+
var ret = {};
|
|
1922
|
+
if(result.success) {
|
|
1923
|
+
ret.success = true;
|
|
1924
|
+
if(result.code != undefined) {
|
|
1925
|
+
ret.code = result.code;
|
|
1926
|
+
ret.message = result.message;
|
|
1927
|
+
}
|
|
1928
|
+
com.veeva.clm.wrapResult("launchSelector", callback, ret);
|
|
1929
|
+
} else {
|
|
1930
|
+
ret.success = false;
|
|
1931
|
+
ret.code = result.code;
|
|
1932
|
+
ret.message = "Request: " + request + " failed: " + result.message;
|
|
1933
|
+
com.veeva.clm.wrapResult("launchSelector", callback, ret);
|
|
1934
|
+
}
|
|
1935
|
+
};
|
|
1936
|
+
|
|
1937
|
+
request = "veeva:launchSelector(" + JSON.stringify(presentationSlides) + "),callback(com_veeva_clm_launchSelector)";
|
|
1938
|
+
|
|
1939
|
+
if(!com.veeva.clm.testMode)
|
|
1940
|
+
com.veeva.clm.runAPIRequest(request);
|
|
1941
|
+
else
|
|
1942
|
+
com_veeva_clm_launchSelector(com.veeva.clm.testResult.launchSelectorResult);
|
|
1943
|
+
|
|
1944
|
+
},
|
|
1945
|
+
|
|
1946
|
+
/////////////////////// Engage ///////////////////////
|
|
1947
|
+
|
|
1948
|
+
// 1,
|
|
1949
|
+
// Creates a new record for Multichannel activity line. The Engage code will automatically fill in the Multichannel Activity,
|
|
1950
|
+
// Asset Version, Asset VExternal ID, Call (if there is one), DateTime, Debug?, Multichannel Content, Multichannel Content Asset,
|
|
1951
|
+
// Sent Email (if there is one), View Order (if Event Type = Slide View). Custom = "True" will always be set and the Name is autonumbered.
|
|
1952
|
+
// If not specified with custom values, Detail Group, Detail Group VExternal Id, Key Message, Key Message VExternal ID, Product,
|
|
1953
|
+
// Product VExternal ID are also automatically filled in.
|
|
1954
|
+
// values - json object with the fields and values updated on the record
|
|
1955
|
+
// callback - call back function which will be used to return the information
|
|
1956
|
+
createMultichannelActivityLine: function(values, callback) {
|
|
1957
|
+
ret = this.checkCallbackFunction(callback);
|
|
1958
|
+
if(ret.success == false)
|
|
1959
|
+
return ret;
|
|
1960
|
+
|
|
1961
|
+
ret = this.checkArgument("values", values);
|
|
1962
|
+
if(ret.success == false) {
|
|
1963
|
+
com.veeva.clm.wrapResult("createMultichannelActivityLine", callback, ret);
|
|
1964
|
+
return;
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
window["com_veeva_clm_createActivityLine"] = function(result) {
|
|
1968
|
+
com.veeva.clm.wrapResult("createMultichannelActivityLine", callback, result);
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
request = "veeva:createActivityLine(),value(" + JSON.stringify(values) + "),com_veeva_clm_createActivityLine(result)";
|
|
1972
|
+
com.veeva.clm.runAPIRequest(request, callback);
|
|
1973
|
+
},
|
|
1974
|
+
|
|
1975
|
+
/////////////////////// Supporting Functions ///////////////////////
|
|
1976
|
+
|
|
1977
|
+
// join string array to a in expression
|
|
1978
|
+
joinStringArrayForIn: function(result) {
|
|
1979
|
+
var ret = "";
|
|
1980
|
+
if(result.length > 0) {
|
|
1981
|
+
for(i = 0; i < result.length; i++) {
|
|
1982
|
+
if(i == 0)
|
|
1983
|
+
ret += "{\"" + result[i] + "\"";
|
|
1984
|
+
else {
|
|
1985
|
+
ret += ",\"" + result[i] + "\"";
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
}
|
|
1989
|
+
ret += "}";
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
return ret;
|
|
1993
|
+
},
|
|
1994
|
+
|
|
1995
|
+
joinFieldArray: function(fields) {
|
|
1996
|
+
var ret = "";
|
|
1997
|
+
if(fields.length > 0) {
|
|
1998
|
+
for(i = 0; i < fields.length; i++) {
|
|
1999
|
+
if(i == 0)
|
|
2000
|
+
ret += fields[i];
|
|
2001
|
+
else {
|
|
2002
|
+
ret += "," + fields[i];
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
return ret;
|
|
2009
|
+
},
|
|
2010
|
+
|
|
2011
|
+
isFunction: function(toCheck) {
|
|
2012
|
+
var getType = {};
|
|
2013
|
+
return toCheck && getType.toString.call(toCheck) === '[object Function]';
|
|
2014
|
+
},
|
|
2015
|
+
|
|
2016
|
+
checkCallbackFunction: function(toCheck) {
|
|
2017
|
+
// check arguments
|
|
2018
|
+
ret = {};
|
|
2019
|
+
if(toCheck == undefined) {
|
|
2020
|
+
ret.success = false;
|
|
2021
|
+
ret.code = 2000
|
|
2022
|
+
ret.message = "callback is missing";
|
|
2023
|
+
return ret;
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
if(this.isFunction(toCheck) == false) {
|
|
2027
|
+
ret.success = false;
|
|
2028
|
+
ret.code = 2001;
|
|
2029
|
+
ret.message = "callback is not a JavaScript function";
|
|
2030
|
+
} else {
|
|
2031
|
+
ret.success = true;
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
return ret;
|
|
2035
|
+
},
|
|
2036
|
+
|
|
2037
|
+
checkArgument: function(name, value) {
|
|
2038
|
+
ret = {};
|
|
2039
|
+
ret.success = true;
|
|
2040
|
+
if(value == undefined || value == null || value == "") {
|
|
2041
|
+
ret.success = false;
|
|
2042
|
+
ret.code = 2002;
|
|
2043
|
+
ret.message = name + " is empty";
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
|
|
2047
|
+
return ret;
|
|
2048
|
+
},
|
|
2049
|
+
|
|
2050
|
+
validateRequestObjectWithErrorMessage: function(request) {
|
|
2051
|
+
var errorString = "";
|
|
2052
|
+
|
|
2053
|
+
//validate that an object is passed in
|
|
2054
|
+
if (typeof request !== "object") {
|
|
2055
|
+
errorString = "Invalid request. Must be an object.";
|
|
2056
|
+
}
|
|
2057
|
+
//validate url
|
|
2058
|
+
//url must be a string
|
|
2059
|
+
//value is required
|
|
2060
|
+
else if (typeof request.url !== "string" || request.url.length <= 0) {
|
|
2061
|
+
errorString = "Invalid URL value. Must be a non-empty String";
|
|
2062
|
+
}
|
|
2063
|
+
//validate method
|
|
2064
|
+
//method must be one of the valid HTTP verbs
|
|
2065
|
+
//optional
|
|
2066
|
+
else if (request.method && !this.validateMethod(request.method)) {
|
|
2067
|
+
errorString = "Invalid method value. Must be a valid HTTP method.";
|
|
2068
|
+
}
|
|
2069
|
+
//validate headers
|
|
2070
|
+
//must be an object whose values are all strings
|
|
2071
|
+
//optional
|
|
2072
|
+
else if (request.headers && !this.validateHeaders(request.headers)) {
|
|
2073
|
+
errorString = "Invalid headers value. Must be an object with values of type String";
|
|
2074
|
+
}
|
|
2075
|
+
//validate timeout
|
|
2076
|
+
//must be a number
|
|
2077
|
+
//optional
|
|
2078
|
+
else if (request.timeout && (typeof request.timeout !== "number" || request.timeout <= 0)) {
|
|
2079
|
+
errorString = "Invalid timeout value. Must be a positive number";
|
|
2080
|
+
}
|
|
2081
|
+
//validate expect
|
|
2082
|
+
//must be a "text" or "blob"
|
|
2083
|
+
//optional
|
|
2084
|
+
else if (request.expect && !this.validateExpect(request.expect)) {
|
|
2085
|
+
errorString = "Invalid expect value. Must be a String of value 'text' or 'blob'";
|
|
2086
|
+
}
|
|
2087
|
+
else {
|
|
2088
|
+
errorString = "Valid";
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
return errorString;
|
|
2092
|
+
},
|
|
2093
|
+
|
|
2094
|
+
methods: ['POST', 'GET', 'HEAD', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'],
|
|
2095
|
+
|
|
2096
|
+
validateMethod: function(method) {
|
|
2097
|
+
return typeof method === "string" && !!~this.methods.indexOf(method.toUpperCase());
|
|
2098
|
+
},
|
|
2099
|
+
|
|
2100
|
+
validateHeaders: function(headers) {
|
|
2101
|
+
if (typeof headers === "object") {
|
|
2102
|
+
var keys = Object.keys(headers);
|
|
2103
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2104
|
+
var key = keys[i];
|
|
2105
|
+
var headerValue = headers[key];
|
|
2106
|
+
if (typeof headerValue !== "string") {
|
|
2107
|
+
return false;
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
} else {
|
|
2111
|
+
return false;
|
|
2112
|
+
}
|
|
2113
|
+
return true;
|
|
2114
|
+
},
|
|
2115
|
+
|
|
2116
|
+
validateExpect: function(expect) {
|
|
2117
|
+
return typeof expect === "string" && (expect.toLowerCase() === "text" || expect.toLowerCase() === "blob");
|
|
2118
|
+
},
|
|
2119
|
+
|
|
2120
|
+
addRequestObjectDefaultsAndFormat: function(request) {
|
|
2121
|
+
if (!request.method) {
|
|
2122
|
+
request.method = "GET";
|
|
2123
|
+
} else {
|
|
2124
|
+
request.method = request.method.toUpperCase();
|
|
2125
|
+
}
|
|
2126
|
+
if (!request.headers) {
|
|
2127
|
+
request.headers = {};
|
|
2128
|
+
}
|
|
2129
|
+
if (!request.timeout) {
|
|
2130
|
+
request.timeout = 30;
|
|
2131
|
+
}
|
|
2132
|
+
if (!request.body) {
|
|
2133
|
+
request.body = "";
|
|
2134
|
+
}
|
|
2135
|
+
if (!request.expect) {
|
|
2136
|
+
request.expect = "text";
|
|
2137
|
+
} else {
|
|
2138
|
+
request.expect = request.expect.toLowerCase();
|
|
2139
|
+
}
|
|
2140
|
+
},
|
|
2141
|
+
|
|
2142
|
+
getCurrentDate: function() {
|
|
2143
|
+
var currentDate = new Date();
|
|
2144
|
+
dateString = currentDate.getFullYear().toString();
|
|
2145
|
+
month = currentDate.getMonth() + 1;
|
|
2146
|
+
if(month < 10) {
|
|
2147
|
+
dateString += "-0" + month;
|
|
2148
|
+
}
|
|
2149
|
+
else {
|
|
2150
|
+
dateString += "-" + month;
|
|
2151
|
+
}
|
|
2152
|
+
date = currentDate.getDate();
|
|
2153
|
+
if(date < 10) {
|
|
2154
|
+
dateString += "-0" + date;
|
|
2155
|
+
} else {
|
|
2156
|
+
dateString += "-" + date;
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
return dateString;
|
|
2160
|
+
},
|
|
2161
|
+
|
|
2162
|
+
formatResult: function(result) {
|
|
2163
|
+
if(com.veeva.clm.isWin8()) {
|
|
2164
|
+
if(typeof result == "string") {
|
|
2165
|
+
result = eval("(" + result + ")");
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
return result;
|
|
2169
|
+
},
|
|
2170
|
+
|
|
2171
|
+
wrapResult: function(apiName, userCallback, result) {
|
|
2172
|
+
result = com.veeva.clm.formatResult(result);
|
|
2173
|
+
if(result.success)
|
|
2174
|
+
userCallback(result);
|
|
2175
|
+
else {
|
|
2176
|
+
result.message = apiName + ": " + result.message;
|
|
2177
|
+
userCallback(result);
|
|
2178
|
+
}
|
|
2179
|
+
},
|
|
2180
|
+
|
|
2181
|
+
runAPIRequest: function(request, callback) {
|
|
2182
|
+
if(com.veeva.clm.isEngage()) {
|
|
2183
|
+
com.veeva.clm.engageAPIRequest(request, callback);
|
|
2184
|
+
} else if(com.veeva.clm.isWin8()) {
|
|
2185
|
+
window.external.notify(request);
|
|
2186
|
+
} else if(com.veeva.clm.isVeevaMessagingEnabled()) {
|
|
2187
|
+
window.webkit.messageHandlers.veeva.postMessage({"message": request});
|
|
2188
|
+
} else {
|
|
2189
|
+
// existing code in this block could be deleted, but to play safe, we keep
|
|
2190
|
+
// as is just in case some legacy applications still need them.
|
|
2191
|
+
// we will eventually remove this code block.
|
|
2192
|
+
request = request.replace(/^veeva:/, '');
|
|
2193
|
+
request = encodeURIComponent(request);
|
|
2194
|
+
request = "veeva:" + request;
|
|
2195
|
+
document.location = request;
|
|
2196
|
+
}
|
|
2197
|
+
},
|
|
2198
|
+
|
|
2199
|
+
isVeevaMessagingEnabled: function() {
|
|
2200
|
+
return Boolean(window.webkit.messageHandlers.veeva);
|
|
2201
|
+
},
|
|
2202
|
+
|
|
2203
|
+
isWin8: function() {
|
|
2204
|
+
if(navigator.platform.toLowerCase().indexOf("win") >= 0)
|
|
2205
|
+
return true;
|
|
2206
|
+
else
|
|
2207
|
+
return false;
|
|
2208
|
+
},
|
|
2209
|
+
|
|
2210
|
+
|
|
2211
|
+
isEngage: function() {
|
|
2212
|
+
if(window.self !== window.top) {
|
|
2213
|
+
return true;
|
|
2214
|
+
}
|
|
2215
|
+
return false;
|
|
2216
|
+
},
|
|
2217
|
+
|
|
2218
|
+
engageAPIRequest: function(request, callback) {
|
|
2219
|
+
if(com.veeva.clm.engageHasListener === false) {
|
|
2220
|
+
com.veeva.clm.engageHasListener = true;
|
|
2221
|
+
com.veeva.clm.engageCallbackId = 0;
|
|
2222
|
+
function receiveMessage(event) {
|
|
2223
|
+
var data = JSON.parse(event.data);
|
|
2224
|
+
var callbackId = data.callback;
|
|
2225
|
+
if(callbackId !== undefined && callbackId !== null) {
|
|
2226
|
+
var callbackFunc = com.veeva.clm.engageCallbackList[callbackId];
|
|
2227
|
+
if(callbackFunc !== undefined && callbackFunc !== null) {
|
|
2228
|
+
callbackFunc.call(null, data);
|
|
2229
|
+
// don't want to splice because that would change the length
|
|
2230
|
+
// of the array and could affect the index based access
|
|
2231
|
+
delete com.veeva.clm.engageCallbackList[callbackId];
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
if(!window.addEventListener) {
|
|
2237
|
+
window.attachEvent("onmessage", receiveMessage);
|
|
2238
|
+
} else {
|
|
2239
|
+
window.addEventListener("message", receiveMessage, false);
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
setTimeout(function() {
|
|
2243
|
+
com.veeva.clm.engageCallbackId += 1;
|
|
2244
|
+
var callbackId = com.veeva.clm.engageCallbackId;
|
|
2245
|
+
com.veeva.clm.engageCallbackList[callbackId] = callback;
|
|
2246
|
+
var tokens = request.split("),");
|
|
2247
|
+
if(tokens.length > 1) {
|
|
2248
|
+
// replace the last token (the original callback) with a callback id
|
|
2249
|
+
tokens[tokens.length - 1 ] = callbackId;
|
|
2250
|
+
request = tokens.join("),");
|
|
2251
|
+
}
|
|
2252
|
+
window.parent.postMessage(request, "*");
|
|
2253
|
+
|
|
2254
|
+
}, 1);
|
|
2255
|
+
},
|
|
2256
|
+
|
|
2257
|
+
listPriceRecordTypeId: null,
|
|
2258
|
+
accountId: null,
|
|
2259
|
+
addressId: null,
|
|
2260
|
+
callId: null,
|
|
2261
|
+
tsfId: null,
|
|
2262
|
+
userId: null,
|
|
2263
|
+
presentationId: null,
|
|
2264
|
+
keyMessageId: null,
|
|
2265
|
+
engageHasListener: false,
|
|
2266
|
+
engageCallbackId: null,
|
|
2267
|
+
engageCallbackList: [],
|
|
2268
|
+
testMode: false,
|
|
2269
|
+
testResult: null
|
|
2270
|
+
|
|
2271
|
+
};
|
|
2272
|
+
|
|
2273
|
+
com.veeva.clm.initialize = function initializeEngage() {
|
|
2274
|
+
var internalMessage = false;
|
|
2275
|
+
var frameScale = 1;
|
|
2276
|
+
|
|
2277
|
+
if(!window.addEventListener) {
|
|
2278
|
+
window.attachEvent("onmessage", engageMessage);
|
|
2279
|
+
} else {
|
|
2280
|
+
window.addEventListener("message", engageMessage, false);
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
document.onmousemove = function(event) {
|
|
2284
|
+
if(internalMessage === true) {
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
var e = event || window.event;
|
|
2289
|
+
sendMouseEvent(e, "mousemove");
|
|
2290
|
+
};
|
|
2291
|
+
|
|
2292
|
+
document.onclick = function(event) {
|
|
2293
|
+
if(internalMessage === true) {
|
|
2294
|
+
return;
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
var e = event || window.event;
|
|
2298
|
+
sendMouseEvent(e, "click");
|
|
2299
|
+
};
|
|
2300
|
+
|
|
2301
|
+
document.onchange = function(event) {
|
|
2302
|
+
if(internalMessage === true) {
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
var e = event || window.event;
|
|
2307
|
+
var target = e.target || e.srcElement;
|
|
2308
|
+
|
|
2309
|
+
if(target) {
|
|
2310
|
+
var eLocation = {};
|
|
2311
|
+
var offsetSum = getOffset(target);
|
|
2312
|
+
eLocation.x = offsetSum.left + target.offsetWidth/2;
|
|
2313
|
+
eLocation.y = offsetSum.top + target.offsetHeight/2;
|
|
2314
|
+
sendChangeEvent("change", target, eLocation);
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
|
|
2318
|
+
document.onkeypress = function(event) {
|
|
2319
|
+
if(internalMessage === true) {
|
|
2320
|
+
return;
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
var e = event || window.event;
|
|
2324
|
+
var target = e.target || e.srcElement;
|
|
2325
|
+
|
|
2326
|
+
if(target) {
|
|
2327
|
+
var keyCode = (typeof e.which === "number") ? e.which : e.keyCode;
|
|
2328
|
+
//Only transmit return keypress
|
|
2329
|
+
if(keyCode === 13) {
|
|
2330
|
+
var eLocation = {};
|
|
2331
|
+
var offsetSum = getOffset(target);
|
|
2332
|
+
eLocation.x = offsetSum.left + target.offsetWidth/2;
|
|
2333
|
+
eLocation.y = offsetSum.top + target.offsetHeight/2;
|
|
2334
|
+
sendKeyboardEvent("keypress", keyCode, eLocation);
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
};
|
|
2338
|
+
|
|
2339
|
+
document.onscroll = function(event) {
|
|
2340
|
+
if(internalMessage === true) {
|
|
2341
|
+
return;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
var e = event || window.event;
|
|
2345
|
+
var target = e.target || e.srcElement;
|
|
2346
|
+
|
|
2347
|
+
if(target) {
|
|
2348
|
+
var scrollPosition = {};
|
|
2349
|
+
if(target.scrollingElement) {
|
|
2350
|
+
scrollPosition.left = target.scrollingElement.scrollLeft;
|
|
2351
|
+
scrollPosition.top = target.scrollingElement.scrollTop;
|
|
2352
|
+
} else if(target.documentElement) {
|
|
2353
|
+
scrollPosition.left = target.documentElement.scrollLeft;
|
|
2354
|
+
scrollPosition.top = target.documentElement.scrollTop;
|
|
2355
|
+
}
|
|
2356
|
+
sendScrollEvent("scroll", scrollPosition);
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
function getOffset(target) {
|
|
2361
|
+
if(target.offsetParent) {
|
|
2362
|
+
var newTarget = target.offsetParent;
|
|
2363
|
+
var offsetSum = getOffset(newTarget);
|
|
2364
|
+
return {
|
|
2365
|
+
left: offsetSum.left + target.offsetLeft,
|
|
2366
|
+
top: offsetSum.top + target.offsetTop
|
|
2367
|
+
}
|
|
2368
|
+
} else {
|
|
2369
|
+
return {
|
|
2370
|
+
left: target.offsetLeft,
|
|
2371
|
+
top: target.offsetTop
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
function sendMouseEvent(event, eventType) {
|
|
2377
|
+
var message = {};
|
|
2378
|
+
message.type = "iframe";
|
|
2379
|
+
message.event = {};
|
|
2380
|
+
message.event.type = eventType;
|
|
2381
|
+
message.event.clientX = event.clientX;
|
|
2382
|
+
message.event.clientY = event.clientY;
|
|
2383
|
+
|
|
2384
|
+
window.parent.postMessage(JSON.stringify(message), "*");
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
function sendChangeEvent(eventType, target, eventLocation) {
|
|
2388
|
+
var message = {};
|
|
2389
|
+
message.type = "iframe";
|
|
2390
|
+
message.event = {};
|
|
2391
|
+
message.event.type = eventType;
|
|
2392
|
+
message.event.value = target.value;
|
|
2393
|
+
message.event.location = eventLocation;
|
|
2394
|
+
|
|
2395
|
+
window.parent.postMessage(JSON.stringify(message), "*");
|
|
2396
|
+
}
|
|
2397
|
+
|
|
2398
|
+
function sendKeyboardEvent(eventType, keyCode, eventLocation) {
|
|
2399
|
+
var message = {};
|
|
2400
|
+
message.type = "iframe";
|
|
2401
|
+
message.event = {};
|
|
2402
|
+
message.event.type = eventType;
|
|
2403
|
+
message.event.keyCode = keyCode;
|
|
2404
|
+
message.event.location = eventLocation;
|
|
2405
|
+
|
|
2406
|
+
window.parent.postMessage(JSON.stringify(message), "*");
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
function sendScrollEvent(eventType, scrollPosition) {
|
|
2410
|
+
var message = {};
|
|
2411
|
+
message.type = "iframe";
|
|
2412
|
+
message.event = {};
|
|
2413
|
+
message.event.type = eventType;
|
|
2414
|
+
message.event.scrollPosition = scrollPosition;
|
|
2415
|
+
|
|
2416
|
+
window.parent.postMessage(JSON.stringify(message), "*");
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
function engageMessage(message) {
|
|
2420
|
+
// var data = JSON.parse(message.data);
|
|
2421
|
+
var data = typeof message.data == 'string' ? JSON.parse(message.data) : message.data;
|
|
2422
|
+
|
|
2423
|
+
if(data.type && data.type === "events") {
|
|
2424
|
+
internalMessage = true;
|
|
2425
|
+
|
|
2426
|
+
// Get scrolling offset
|
|
2427
|
+
var scrollX = 0;
|
|
2428
|
+
var scrollY = 0;
|
|
2429
|
+
if(document.scrollingElement) {
|
|
2430
|
+
scrollX = document.scrollingElement.scrollLeft;
|
|
2431
|
+
scrollY = document.scrollingElement.scrollTop;
|
|
2432
|
+
} else if(document.documentElement) {
|
|
2433
|
+
scrollX = document.documentElement.scrollLeft;
|
|
2434
|
+
scrollY = document.documentElement.scrollTop;
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
if(data.event.type === "change") {
|
|
2438
|
+
data.event.location.x -= scrollX;
|
|
2439
|
+
data.event.location.y -= scrollY;
|
|
2440
|
+
|
|
2441
|
+
if(frameScale) {
|
|
2442
|
+
data.event.location.x *= frameScale;
|
|
2443
|
+
data.event.location.y *= frameScale;
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
var target = document.elementFromPoint(data.event.location.x, data.event.location.y);
|
|
2447
|
+
if(target) {
|
|
2448
|
+
simulateChangeEvent(target, data);
|
|
2449
|
+
}
|
|
2450
|
+
} else if(data.event.type === "keypress") {
|
|
2451
|
+
data.event.location.x -= scrollX;
|
|
2452
|
+
data.event.location.y -= scrollY;
|
|
2453
|
+
|
|
2454
|
+
if(frameScale) {
|
|
2455
|
+
data.event.location.x *= frameScale;
|
|
2456
|
+
data.event.location.y *= frameScale;
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2459
|
+
var target = document.elementFromPoint(data.event.location.x, data.event.location.y);
|
|
2460
|
+
if(target) {
|
|
2461
|
+
simulateKeypressEvent(target, data);
|
|
2462
|
+
}
|
|
2463
|
+
} else if(data.event.type === "scroll") {
|
|
2464
|
+
simulateScrollEvent(data);
|
|
2465
|
+
} else {
|
|
2466
|
+
var target = document.elementFromPoint(data.event.clientX, data.event.clientY);
|
|
2467
|
+
if(target) {
|
|
2468
|
+
simulateMouseEvent(target, data);
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
} else if(data.type && data.type === "scale") {
|
|
2472
|
+
if(typeof data.value === "number" && data.value > 0) {
|
|
2473
|
+
frameScale = data.value;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
function simulateChangeEvent(target, data) {
|
|
2479
|
+
target.value = data.event.value;
|
|
2480
|
+
var evt = htmlEvent(data.event.type);
|
|
2481
|
+
dispatchEvent(target, evt, data.event.type);
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
function simulateKeypressEvent(target, data) {
|
|
2485
|
+
//Treat the keypress event as a click event since keypress event does not work in some content
|
|
2486
|
+
var evt = mouseEvent("click", 0, 0, data.event.location.x, data.event.location.y);
|
|
2487
|
+
dispatchEvent(target, evt, "click");
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
function simulateScrollEvent(data) {
|
|
2491
|
+
var scrollPosition = data.event.scrollPosition;
|
|
2492
|
+
|
|
2493
|
+
if(document.scrollingElement) {
|
|
2494
|
+
document.scrollingElement.scrollLeft = scrollPosition.left;
|
|
2495
|
+
document.scrollingElement.scrollTop = scrollPosition.top;
|
|
2496
|
+
} else if(document.documentElement) {
|
|
2497
|
+
document.documentElement.scrollLeft = scrollPosition.left;
|
|
2498
|
+
document.documentElement.scrollTop = scrollPosition.top;
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
function simulateMouseEvent(target, data) {
|
|
2503
|
+
var evt = mouseEvent(data.event.type, 0, 0, data.event.clientX, data.event.clientY);
|
|
2504
|
+
dispatchEvent(target, evt, data.event.type);
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
function htmlEvent(type) {
|
|
2508
|
+
var evt;
|
|
2509
|
+
var e = {
|
|
2510
|
+
bubbles: true,
|
|
2511
|
+
cancelable: true
|
|
2512
|
+
};
|
|
2513
|
+
if (typeof( document.createEvent ) == "function") {
|
|
2514
|
+
evt = document.createEvent("HTMLEvents");
|
|
2515
|
+
evt.initEvent(type, e.bubbles, e.cancelable);
|
|
2516
|
+
} else if (document.createEventObject) {
|
|
2517
|
+
evt = document.createEventObject();
|
|
2518
|
+
evt.eventType = type;
|
|
2519
|
+
for (prop in e) {
|
|
2520
|
+
evt[prop] = e[prop];
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
return evt;
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
function mouseEvent(type, sx, sy, cx, cy) {
|
|
2527
|
+
var evt;
|
|
2528
|
+
var e = {
|
|
2529
|
+
bubbles: true,
|
|
2530
|
+
cancelable: (type != "mousemove"),
|
|
2531
|
+
view: window,
|
|
2532
|
+
detail: 0,
|
|
2533
|
+
screenX: sx,
|
|
2534
|
+
screenY: sy,
|
|
2535
|
+
clientX: cx,
|
|
2536
|
+
clientY: cy,
|
|
2537
|
+
ctrlKey: false,
|
|
2538
|
+
altKey: false,
|
|
2539
|
+
shiftKey: false,
|
|
2540
|
+
metaKey: false,
|
|
2541
|
+
button: 0,
|
|
2542
|
+
relatedTarget: undefined
|
|
2543
|
+
};
|
|
2544
|
+
if (typeof( document.createEvent ) == "function") {
|
|
2545
|
+
evt = document.createEvent("MouseEvents");
|
|
2546
|
+
evt.initMouseEvent(type,
|
|
2547
|
+
e.bubbles, e.cancelable, e.view, e.detail,
|
|
2548
|
+
e.screenX, e.screenY, e.clientX, e.clientY,
|
|
2549
|
+
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
|
|
2550
|
+
e.button, document.body.parentNode);
|
|
2551
|
+
} else if (document.createEventObject) {
|
|
2552
|
+
evt = document.createEventObject();
|
|
2553
|
+
for (prop in e) {
|
|
2554
|
+
evt[prop] = e[prop];
|
|
2555
|
+
}
|
|
2556
|
+
evt.button = { 0:1, 1:4, 2:2 }[evt.button] || evt.button;
|
|
2557
|
+
}
|
|
2558
|
+
return evt;
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
function dispatchEvent (el, evt, type) {
|
|
2562
|
+
if (el.dispatchEvent) {
|
|
2563
|
+
el.dispatchEvent(evt);
|
|
2564
|
+
} else if (el.fireEvent) {
|
|
2565
|
+
el.fireEvent('on' + type, evt);
|
|
2566
|
+
}
|
|
2567
|
+
return evt;
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
|
|
2571
|
+
};
|
|
2572
|
+
|
|
2573
|
+
|
|
2574
|
+
//support functions to allow Windows Modern to support the OnExit functions
|
|
2575
|
+
com_veeva_clm_createRecordsOnExit = function() {
|
|
2576
|
+
return com.veeva.clm.createRecordsOnExit();
|
|
2577
|
+
}
|
|
2578
|
+
com_veeva_clm_updateRecordsOnExit = function() {
|
|
2579
|
+
return com.veeva.clm.updateRecordsOnExit();
|
|
2580
|
+
}
|
|
2581
|
+
com_veeva_clm_updateCurrentRecordsOnExit = function() {
|
|
2582
|
+
return com.veeva.clm.updateCurrentRecordsOnExit();
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
|
|
2586
|
+
com.veeva.clm.initialize();
|