Skip to content

Commit e9139a5

Browse files
authored
Update README.md
1 parent 2bc7dc4 commit e9139a5

File tree

1 file changed

+83
-2
lines changed

1 file changed

+83
-2
lines changed

README.md

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,88 @@ WebApiClient.Delete(request)
108108
});
109109
```
110110

111+
### Associate
112+
Associate requests are supported. You have to pass the relationship name, a source and a target entity.
113+
This example associates an opportuntiy to an account:
114+
115+
```JavaScript
116+
var request = {
117+
relationShip: "opportunity_customer_accounts",
118+
source:
119+
{
120+
entityName: "opportunity",
121+
entityId: "00000000-0000-0000-0000-000000000001"
122+
},
123+
target:
124+
{
125+
entityName: "account",
126+
entityId: "00000000-0000-0000-0000-000000000002"
127+
}
128+
};
129+
130+
WebApiClient.Associate(request)
131+
.then(function(response){
132+
// Process response
133+
})
134+
.catch(function(error) {
135+
// Handle error
136+
});
137+
```
138+
139+
### Disassociate
140+
Disassociate requests are supported. You have to pass the relationship name, a source and a target entity.
141+
This example disassociates an opportuntiy from an account:
142+
143+
```JavaScript
144+
var request = {
145+
relationShip: "opportunity_customer_accounts",
146+
source:
147+
{
148+
entityName: "opportunity",
149+
entityId: "00000000-0000-0000-0000-000000000001"
150+
},
151+
target:
152+
{
153+
entityName: "account",
154+
entityId: "00000000-0000-0000-0000-000000000002"
155+
}
156+
};
157+
158+
WebApiClient.Disassociate(request)
159+
.then(function(response){
160+
// Process response
161+
})
162+
.catch(function(error) {
163+
// Handle error
164+
});
165+
```
166+
167+
### Promises
168+
This client uses bluebird for handling promises in a cross-browser compliant way.
169+
For this reason bluebird is exported as global implementation of promises (and also overrides browser native Promises).
170+
The decision to override native Promises was made to give you a constant usage experience across all browsers.
171+
172+
Using promises you can do something like this, too:
173+
```Javascript
174+
var requests = [];
175+
176+
for (var i = 0; i < 5; i++) {
177+
var request = {
178+
entityName: "account",
179+
entity: {name: "Adventure Works Nr. " + i}
180+
};
181+
requests.push(WebApiClient.Create(request));
182+
}
183+
184+
Promise.all(requests)
185+
.then(function(response){
186+
// Process response
187+
})
188+
.catch(function(error) {
189+
// Handle error
190+
});
191+
```
192+
111193
## Headers
112194

113195
### Header Format
@@ -139,9 +221,8 @@ var request = {
139221
entity: {name: "Adventure Works"},
140222
headers: [ { key: "headerKey", value: "headerValue" }]
141223
};
142-
143-
Note: Currently your request headers are simply added after the default headers. Watch out for interferences.
144224
```
225+
Note: Currently your request headers are simply added after the default headers. Watch out for interferences.
145226

146227
### API Version
147228
The default API version is 8.0.

0 commit comments

Comments
 (0)