forked from jeffdonthemic/node-red-contrib-salesforce
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdml.html
100 lines (98 loc) · 4.1 KB
/
dml.html
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
<script type="text/javascript">
RED.nodes.registerType('dml',{
category: 'Salesforce',
color: '#C0DEED',
defaults: {
name: {value: ''},
object: {value: '', required: true},
action: {value: 'insert', required: true},
connection: {value: '', type: 'connection-config', required: true}
},
inputs:1,
outputs:1,
icon: "salesforce.png",
align: "right",
label: function() {
return this.name || 'dml';
}
});
</script>
<script type="text/x-red" data-template-name="dml">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-connection"><i class="fa fa-plug"></i> Connection</label>
<input type="text" id="node-input-connection">
</div>
<div class="form-row">
<label for="node-input-object"><i class="fa fa-cubes"></i> Object</label>
<input type="text" id="node-input-object" placeholder="ex Acccount or MyObject__c">
</div>
<div class="form-row">
<label for="node-input-action"><i class="fa fa-wrench"></i> Action</label>
<select id="node-input-action">
<option value="insert">Insert</option>
<option value="update">Update</option>
<option value="upsert">Upsert</option>
<option value="delete">Delete</option>
</select>
</div>
</script>
<script type="text/x-red" data-help-name="dml">
<p>Executes an insert, update, upsert or delete DML statement.</p>
<p>The action and object can be configured in the node, however if left blank, the following should be set in an incoming message:<ul><li><code>msg.action</code> - the DML action to perform</li><li><code>msg.object</code> - the sObject for the DML action</li></ul></p>
<p><b>Insert Action</b></p>
<p>This action inserts the contents of <code>msg.payload</code> and returns the newly created ID.</p>
<pre>{
firstname: "Nikola",
lastname: "Tesla"
}</pre>
<p><br/><b>Update Action</b></p>
<p>This action updates the specified record with the the contents of <code>msg.payload</code>. It assumes that the payload contains an <code>id</code> property with the id of the record to be updated.</p>
<pre>{
id: "00337000002uFbW",
firstname: "Nikola",
lastname: "Tesla"
}</pre>
<p><br/><b>Upsert Action</b></p>
<p>The upsert action matches contents of the <code>msg.payload</code> with existing records by comparing values of one field. If you don’t specify a field when calling this action, the operation uses the id value in the <code>msg.payload</code> to match with existing records to update. Alternatively, you can specify a field to use for matching in <code>msg.externalId</code>. This field must be marked as external ID. If a matching record is not found, a new records is inserted.</p>
<p>Sample <code>msg.payload</code> to be used with an external id.</p>
<pre>{
firstname: "Nikola",
lastname: "Tesla"
}</pre>
<p>Sample <code>msg.externalId</code> specifying the field and value to be used for matching.</p>
<pre>{
field: "Ext_ID__c",
value: "12345"
}</pre>
<p>If record(s) are updated, the resulting payload will resemble:</p>
<pre>{
"payload": {
"success": true,
"object": "contact",
"id": {
"field": "Ext_ID__c",
"value": "12345"
},
"action": "update"
}
}</pre>
<p>If a new record is inserted, the resulting payload will resemble the following containing the id of the newly created record:</p>
<pre>{
"payload": {
"success": true,
"object": "contact",
"id": "00337000002uwUVAAY",
"action": "insert"
}
}</pre>
<p><br/><b>Delete Action</b></p>
<p>This action deletes the record specified by the id property in <code>msg.payload</code>.</p>
<pre>{
"id": "00337000002uwUVAAY"
}</pre>
<p>See the <a href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_section.htm#apex_dml_insert" target="_blank">Apex DML Operations</a> for more information.</p>
</script>