Open jacobweber opened 1 year ago
that does seem to be the case. PR welcomed, otherwise I'll try to get around to it when I can!
@jacobweber I just tested this with a custom apex invocable:
public class AccountInsertAction {
@InvocableMethod(label='Insert Accounts' description='Inserts the accounts specified and returns the IDs of the new accounts.')
public static List<ID> insertAccounts(List<Account> accounts) {
Database.SaveResult[] results = Database.insert(accounts);
List<ID> accountIds = new List<ID>();
for (Database.SaveResult result : results) {
if (result.isSuccess()) {
accountIds.add(result.getId());
}
}
return accountIds;
}
}
And the output does match the current types.
[
{
actionName: 'AccountInsertAction',
errors: null,
isSuccess: true,
outputValues: { output: '0018W00002RQBBpQAP' },
version: 1
},
{
actionName: 'AccountInsertAction',
errors: null,
isSuccess: true,
outputValues: { output: '0018W00002RQBBqQAP' },
version: 1
}
]
Maybe it's different for the standard invocable actions? Have do you have a reproducible example?
I do; for example, my action code looks something like:
public class GetPhotosAction {
@InvocableMethod()
public static List<Response> getPhotos() {
List<Response> responses = new List<Response>();
...
Response response = new Response();
response.fullPhoto = 'full';
response.smallPhoto = 'small';
responses.add(response);
}
public class Response {
@InvocableVariable(required=false)
public String fullPhoto;
@InvocableVariable(required=false)
public String smallPhoto;
}
}
and it returns:
[
{
"actionName": "GetPhotosAction",
"errors": null,
"isSuccess": true,
"outputValues": {
"fullPhoto": "full",
"smallPhoto": "small"
},
"version": 1
}
]
Maybe it's adding that "object" key when the list item serializes to a single value instead of an object? Not sure....there's not a lot of clear documentation.
If I call
rest.invokeAction<ResponseType>
, the TypeScript definitions and documentation say that it returns something like:I think this is incorrect —
outputValues
should actually be an object of type ResponseType, and shouldn't contain an "output" field. If I log the response, that's what it contains, and it's consistent with the example in the actions developer guide.