-
Notifications
You must be signed in to change notification settings - Fork 1
/
Library Visit Form.js
84 lines (83 loc) · 4.17 KB
/
Library Visit Form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
each(dataPath("data[*]"),
combine(
upsert("Reporting__c","Unique_ID__c",fields(
field("Unique_ID__c", dataValue("instanceID")),
field("Province__c", function(state){
if (state.data.province !== (undefined || null)) {
return dataValue("province")(state).toString().replace(new RegExp("_","g")," ")
} else {
null
}
}),
field("Story_Sparker__c", function(state){
if (state.data.lm === ("0030N00002wEFIkQAO"))
{return "0030N00002qNItEQAW"}
if (state.data.lm === ("0030N00002wELVBQA4"))
{return "0030N00002b1cpjQAA"}
if (state.data.lm !== ("lm_other")) {
return dataValue("lm")(state)
} else {
return "0030N00002HkYUwQAN"
}
}),
field("RecordTypeID", "0120N0000001X2iQAE"),
field("Other_Story_Sparker__c", dataValue("lm_other")),
field("Date_of_visit__c", dataValue("date")),
field("GPS_Location__c", dataValue("longitude")),
field("GPS_Location__c", dataValue("lattitude")),
field("Visit_Partner_Name_of_partner_org__c", dataValue("partner")),
field("Time_In__c", function(state)
{ const timeArray = state.data.time_in.split(':');
var hour = parseInt(timeArray[0]);
if (hour < 21)
{hour = hour + 2}
else {
hour = hour + 2 - 24;}
const strHour = (hour < 10 ? '0' + hour : '' + hour);
return [strHour, timeArray[1], timeArray[2]].join(':')
}),
field("Were_books_checked_out_returned_today__c", dataValue("books_lent")),
field("No_adults_checked_out_books_today__c", dataValue("no_adults")),
field("No_children_checked_out_books_today__c", dataValue("no_children")),
field("Any_special_books_t__c", dataValue("requests_YN")),
field("Special_book_requests__c", dataValue("special_request")),
field("Activities_Completed__c", function(state) {
if (state.activities !== (undefined || null))
{ return Array.apply(
null, dataValue("activities")(state)
).join(';').replace(/_/g," ")
}}),
field("Other_Activities_1__c", dataValue("other_activity")),
field("Do_you_know_actual_approximate_number__c", dataValue("number_known")),
field("Actual_no_of_participants__c", dataValue("actual")),
field("Approximate_no_of_participants__c", dataValue("approximate")),
field("Challenges_to_report__c", dataValue("select_challenges")),
field("Any_challenges_experienced__c", dataValue("challenges")),
field("Positive_highlights_to_share__c", dataValue("select_success")),
field("Positive_highlights__c", dataValue("successes")),
field("Time_Out__c", function(state)
{ const timeArray = state.data.time_out.split(':');
var hour = parseInt(timeArray[0]);
if (hour < 21)
{hour = hour + 2}
else {
hour = hour + 2 - 24;}
const strHour = (hour < 10 ? '0' + hour : '' + hour);
return [strHour, timeArray[1], timeArray[2]].join(':')
}),
field("No_of_books_returned__c", dataValue("no_books_returned")),
field("No_of_books_overdue__c", dataValue("no_books_outstanding"))
)),
each(
// merge(dataPath("checkout_repeat[*]"),fields(
// field("whoID", dataValue("who"))),
dataPath("books_repeat[*]"),
// fields(
// field("parentId", dataValue("instanceID")),
create("Book_Checkout__c",fields(
relationship("SPM_Book__r","Unique_ID__c",dataValue("scan")),
relationship("Reporting__r","Unique_ID__c",dataValue("parentId")),
relationship("Book_Checked_Out_By__r","Library_Card__c",dataValue("whoID")),
field("Checkout_Status__c", dataValue("book_status")))
))))
));