forked from rmuit/PracticalAfas
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKnOrg-embedded-upsert.txt
108 lines (108 loc) · 3.54 KB
/
KnOrg-embedded-upsert.txt
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
; This represents an insert of a new contact/person object inside an existing
; organisation object. If the organisation data/address does not change, the
; 'name' and 'address' fields/objects are not necessary.
; We always specify action "update" just to be sure, for XML updates; see
; KnOrg-embedded-update.txt.
; We need to specify DEFAULT_CHANGE | ALLOW_CHANGES to get In & SeNm populated
; and to split the house number off the street field.
KnOrganisation:update:55
[
'code' => '1100000',
'name' => 'Wyz',
'contact' => [
'email' => '[email protected]',
'phone' => '06-22517218',
'person' => [
'first_name' => 'Roderik',
'last_name' => 'v. Muit',
],
],
]
; After creating the object with above data and "update" action, we need to set
; the embedded contact/organisation data to be an "insert" instead:
eval: $object->getObject('KnContact')->setAction('insert');
--
; Note: I have never tried this insert-inside-an-update in JSON/REST. It may
; work with the PUT 'endpoint' because of the MatchPer value - but someone will
; need to test this.
{
"KnOrganisation": {
"Element": {
"Fields": {
; MatchOga is set to 0 by default, for most updates.
"BcCo": "1100000",
"Nm": "Wyz",
"MatchOga": 0
},
"Objects": {
"KnContact": {
"Element": {
"Fields": {
"TeNr": "06-22517218",
"EmAd": "[email protected]",
"ViKc": "PRS"
},
"Objects": {
"KnPerson": {
"Element": {
"Fields": {
"FiNm": "Roderik",
"LaNm": "Muit",
"Is": "v.",
"In": "R.",
"SeNm": "MUIT",
"SpNm": false,
"ViGe": "O",
"Corr": false,
"AutoNum": true,
; MatchPer has a default of 7 (for inserts).
"MatchPer": 7
}
}
}
}
}
}
}
}
}
}
--
<KnOrganisation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Element>
<Fields Action="update">
<BcCo>1100000</BcCo>
<Nm>Wyz</Nm>
<MatchOga>0</MatchOga>
</Fields>
<Objects>
<KnContact>
<Element>
<Fields Action="insert">
<TeNr>06-22517218</TeNr>
<EmAd>[email protected]</EmAd>
<ViKc>PRS</ViKc>
</Fields>
<Objects>
<KnPerson>
<Element>
<Fields Action="insert">
<FiNm>Roderik</FiNm>
<LaNm>Muit</LaNm>
<Is>v.</Is>
<In>R.</In>
<SeNm>MUIT</SeNm>
<SpNm>0</SpNm>
<ViGe>O</ViGe>
<Corr>0</Corr>
<AutoNum>1</AutoNum>
<MatchPer>7</MatchPer>
</Fields>
</Element>
</KnPerson>
</Objects>
</Element>
</KnContact>
</Objects>
</Element>
</KnOrganisation>