Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 37 additions & 13 deletions mdl-examples/doctype-tests/10-odata-examples.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,19 @@ from odata client OdTest.SalesforceAPI
* Level 8.6c: Create external entity with AllowCreateChangeLocally flag
* Enables local creation/changes for the entity, mirroring Studio Pro's
* "Allow creating and changing locally" checkbox on external entities.
*
* RemoteName must be repeated here because `create or modify external entity`
* currently overwrites omitted properties with empty strings rather than
* preserving the existing value. Without `RemoteName: 'Account'`, the BSON
* ends up with `"RemoteName": ""`, which Studio Pro's Integration Pane
* visualiser cannot render (NRE in ODataRemoteEntitySource.RemoteId,
* mxcli#594).
*/
create or modify external entity OdTest.RemoteAccount
from odata client OdTest.SalesforceAPI
(
EntitySet: 'Accounts',
RemoteName: 'Account',
Countable: Yes,
Creatable: Yes,
Deletable: No,
Expand Down Expand Up @@ -378,16 +386,15 @@ revoke access on odata service OdTest.CustomerAPI from OdTest.user;
-- LEVEL 9: EXTERNAL ACTION CALLS IN MICROFLOWS
-- ############################################################################

/**
* Level 9.1: Call an external action with parameters and result variable
*/
create microflow OdTest.ACT_CallExternalAction() returns boolean
begin
$Result = call external action OdTest.SalesforceAPI.GetAccounts(status = 'active', Region = $SelectedRegion);
call external action OdTest.SalesforceAPI.NotifyUpdate(AccountId = $AccountId) on error continue;
return true;
end;
/
-- Level 9.1: Call an external action — see Level 10.4.1 below.
--
-- The microflow is created after Level 10.1 because Studio Pro resolves
-- `call external action` Name fields against the cached $metadata schema of
-- the ConsumedODataService. SalesforceAPI's MetadataUrl is a placeholder
-- that doesn't actually return $metadata, so its cache is empty and any
-- action call against it would crash Studio Pro's project checker with a
-- NullReferenceException in CallExternalAction.SchemaAction (see mxcli#590).
-- TripPin has reachable metadata, so its actions resolve correctly.

/**
* Level 9.2: Show external actions discovered from microflow usage
Expand Down Expand Up @@ -462,14 +469,31 @@ create or modify external entities from TripPinClient."TripPinApiClient"
into TripPinClient;
/

/**
* Level 10.4.1: Demonstrate `call external action` against TripPin schema
* actions. Both ResetDataSource (no parameters) and GetNearestAirport
* (parameterised with a return variable) are unbound entries in TripPin's
* cached $metadata, so Studio Pro's project checker resolves SchemaAction
* correctly. The microflow lives in OdTest to keep `show external actions
* in OdTest` (Level 9.2) returning a row, but references the TripPin client.
*/
create microflow OdTest.ACT_CallExternalAction() returns boolean
begin
$Airport = call external action TripPinClient."TripPinApiClient".GetNearestAirport(lat = 47.6062, lon = -122.3321);
call external action TripPinClient."TripPinApiClient".ResetDataSource() on error continue;
return true;
end;
/

-- ############################################################################
-- LEVEL 8.8: DROP (cleanup)
-- ############################################################################

/**
* Level 8.8a: Drop objects that reference SalesforceAPI before dropping the client.
* OdTest.ACT_CallExternalAction calls SalesforceAPI actions; OdTest.RemoteAccount
* is an external entity backed by SalesforceAPI — both must be removed first.
* Level 8.8a: Drop objects that reference OData clients before dropping the
* clients themselves. OdTest.ACT_CallExternalAction (created in Level 10.4.1)
* calls TripPin actions, and OdTest.RemoteAccount is an external entity
* backed by SalesforceAPI — both must be removed first.
*/
drop microflow OdTest.ACT_CallExternalAction;
/
Expand Down
Loading