Standard invocable actions API: How to detect whether an input expects an array?
up vote
4
down vote
favorite
I'm working on some functionality that calls some standard invocable actions via Salesforce's REST API (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_actions_invocable_standard.htm). I'm providing a list of inputs to an end user, then I make the call to the invocable action with the values the user provides for these inputs.
I'd like to build this list of inputs dynamically, based on Salesforce's current API. Therefore, I'm currently using the response from the standard action's endpoint to get the expected inputs. For example, for the "Submit for Approval" action, I make a call to m/services/data/v42.0/actions/standard/submit
, which returns a description of the action in the response, including a list of the expected inputs. I then use the list of inputs
from the JSON response to build inputs for the user.
The problem I'm encountering is, it looks like some of these inputs expect an "array", but I don't see any indicator from the initial response that these inputs accept an array. For example, compare the description of the objectId
input (which expects a string) with that of the nextApproverId
input (which expects an array):
inputs: {
0: {
byteLength: 18,
description: "Required. The ID of the record being submitted for approval.",
label: "Record ID",
maxOccurs: 1,
name: "objectId",
picklistValues: null,
required: true,
sobjectType: null,
type: "REFERENCE",
},
...
3: {
byteLength: 0,
description: ""Optional. An array of one ID of the next approver, which can be a user or a group. Optional since some approval processes have the next approver(s) specified in the approval process definition.",
label: "Next Approver IDs",
maxOccurs: 2000,
name: "nextApproverIds",
picklistValues: null,
required: false,
sobjectType: null,
type: "REFERENCE",
}
}
While the description for the nextApproverIds
input indicates that it expects an array, there's no actual parameter that indicates this (the type
for both inputs is "REFERENCE"). Therefore, I can't dynamically determine how to format the call to this action. Has anyone encountered this? Do you know of a workaround for this issue?
Thanks!
rest-api invocable-method
add a comment |
up vote
4
down vote
favorite
I'm working on some functionality that calls some standard invocable actions via Salesforce's REST API (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_actions_invocable_standard.htm). I'm providing a list of inputs to an end user, then I make the call to the invocable action with the values the user provides for these inputs.
I'd like to build this list of inputs dynamically, based on Salesforce's current API. Therefore, I'm currently using the response from the standard action's endpoint to get the expected inputs. For example, for the "Submit for Approval" action, I make a call to m/services/data/v42.0/actions/standard/submit
, which returns a description of the action in the response, including a list of the expected inputs. I then use the list of inputs
from the JSON response to build inputs for the user.
The problem I'm encountering is, it looks like some of these inputs expect an "array", but I don't see any indicator from the initial response that these inputs accept an array. For example, compare the description of the objectId
input (which expects a string) with that of the nextApproverId
input (which expects an array):
inputs: {
0: {
byteLength: 18,
description: "Required. The ID of the record being submitted for approval.",
label: "Record ID",
maxOccurs: 1,
name: "objectId",
picklistValues: null,
required: true,
sobjectType: null,
type: "REFERENCE",
},
...
3: {
byteLength: 0,
description: ""Optional. An array of one ID of the next approver, which can be a user or a group. Optional since some approval processes have the next approver(s) specified in the approval process definition.",
label: "Next Approver IDs",
maxOccurs: 2000,
name: "nextApproverIds",
picklistValues: null,
required: false,
sobjectType: null,
type: "REFERENCE",
}
}
While the description for the nextApproverIds
input indicates that it expects an array, there's no actual parameter that indicates this (the type
for both inputs is "REFERENCE"). Therefore, I can't dynamically determine how to format the call to this action. Has anyone encountered this? Do you know of a workaround for this issue?
Thanks!
rest-api invocable-method
Is your question as how do you identify if an input expects array vs. a single element?
– Jayant Das
16 hours ago
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I'm working on some functionality that calls some standard invocable actions via Salesforce's REST API (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_actions_invocable_standard.htm). I'm providing a list of inputs to an end user, then I make the call to the invocable action with the values the user provides for these inputs.
I'd like to build this list of inputs dynamically, based on Salesforce's current API. Therefore, I'm currently using the response from the standard action's endpoint to get the expected inputs. For example, for the "Submit for Approval" action, I make a call to m/services/data/v42.0/actions/standard/submit
, which returns a description of the action in the response, including a list of the expected inputs. I then use the list of inputs
from the JSON response to build inputs for the user.
The problem I'm encountering is, it looks like some of these inputs expect an "array", but I don't see any indicator from the initial response that these inputs accept an array. For example, compare the description of the objectId
input (which expects a string) with that of the nextApproverId
input (which expects an array):
inputs: {
0: {
byteLength: 18,
description: "Required. The ID of the record being submitted for approval.",
label: "Record ID",
maxOccurs: 1,
name: "objectId",
picklistValues: null,
required: true,
sobjectType: null,
type: "REFERENCE",
},
...
3: {
byteLength: 0,
description: ""Optional. An array of one ID of the next approver, which can be a user or a group. Optional since some approval processes have the next approver(s) specified in the approval process definition.",
label: "Next Approver IDs",
maxOccurs: 2000,
name: "nextApproverIds",
picklistValues: null,
required: false,
sobjectType: null,
type: "REFERENCE",
}
}
While the description for the nextApproverIds
input indicates that it expects an array, there's no actual parameter that indicates this (the type
for both inputs is "REFERENCE"). Therefore, I can't dynamically determine how to format the call to this action. Has anyone encountered this? Do you know of a workaround for this issue?
Thanks!
rest-api invocable-method
I'm working on some functionality that calls some standard invocable actions via Salesforce's REST API (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_actions_invocable_standard.htm). I'm providing a list of inputs to an end user, then I make the call to the invocable action with the values the user provides for these inputs.
I'd like to build this list of inputs dynamically, based on Salesforce's current API. Therefore, I'm currently using the response from the standard action's endpoint to get the expected inputs. For example, for the "Submit for Approval" action, I make a call to m/services/data/v42.0/actions/standard/submit
, which returns a description of the action in the response, including a list of the expected inputs. I then use the list of inputs
from the JSON response to build inputs for the user.
The problem I'm encountering is, it looks like some of these inputs expect an "array", but I don't see any indicator from the initial response that these inputs accept an array. For example, compare the description of the objectId
input (which expects a string) with that of the nextApproverId
input (which expects an array):
inputs: {
0: {
byteLength: 18,
description: "Required. The ID of the record being submitted for approval.",
label: "Record ID",
maxOccurs: 1,
name: "objectId",
picklistValues: null,
required: true,
sobjectType: null,
type: "REFERENCE",
},
...
3: {
byteLength: 0,
description: ""Optional. An array of one ID of the next approver, which can be a user or a group. Optional since some approval processes have the next approver(s) specified in the approval process definition.",
label: "Next Approver IDs",
maxOccurs: 2000,
name: "nextApproverIds",
picklistValues: null,
required: false,
sobjectType: null,
type: "REFERENCE",
}
}
While the description for the nextApproverIds
input indicates that it expects an array, there's no actual parameter that indicates this (the type
for both inputs is "REFERENCE"). Therefore, I can't dynamically determine how to format the call to this action. Has anyone encountered this? Do you know of a workaround for this issue?
Thanks!
rest-api invocable-method
rest-api invocable-method
edited 16 hours ago
Jayant Das
11.1k2523
11.1k2523
asked 16 hours ago
Emily Davis
915
915
Is your question as how do you identify if an input expects array vs. a single element?
– Jayant Das
16 hours ago
add a comment |
Is your question as how do you identify if an input expects array vs. a single element?
– Jayant Das
16 hours ago
Is your question as how do you identify if an input expects array vs. a single element?
– Jayant Das
16 hours ago
Is your question as how do you identify if an input expects array vs. a single element?
– Jayant Das
16 hours ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
5
down vote
accepted
If I understand your question, you are looking for a way to identify if an input is array or not.
While the description for the
nextApproverIds
input indicates that it expects an array, there's no actual parameter that indicates this
In fact, there is an attribute maxOccurs
, that determines if an element is expected more than once. You can use it to to identify if you need to pass an array. This attribute, if declared with the value of 1 would mean it expects only one parameter, anything more than 1 can be treated as an array. You can find more details on this attribute on XML Occurrence Constraints.
The maximum number of times an element may appear is determined by the value of a
maxOccurs
attribute in its declaration
1
Yes, Jayant, that's what I'm looking for. I was not sure what themaxOccurs
attribute was for, but it looks like that might solve my problem! Thanks for the input.
– Emily Davis
14 hours ago
add a comment |
up vote
0
down vote
Not the best way, but you can see the type in the description field.
If description contains keyword "Array" its an array
Thanks Pranay, but I'd really rather not rely on the description, since that's not really a reliable way to know that an input expects an array.
– Emily Davis
16 hours ago
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
If I understand your question, you are looking for a way to identify if an input is array or not.
While the description for the
nextApproverIds
input indicates that it expects an array, there's no actual parameter that indicates this
In fact, there is an attribute maxOccurs
, that determines if an element is expected more than once. You can use it to to identify if you need to pass an array. This attribute, if declared with the value of 1 would mean it expects only one parameter, anything more than 1 can be treated as an array. You can find more details on this attribute on XML Occurrence Constraints.
The maximum number of times an element may appear is determined by the value of a
maxOccurs
attribute in its declaration
1
Yes, Jayant, that's what I'm looking for. I was not sure what themaxOccurs
attribute was for, but it looks like that might solve my problem! Thanks for the input.
– Emily Davis
14 hours ago
add a comment |
up vote
5
down vote
accepted
If I understand your question, you are looking for a way to identify if an input is array or not.
While the description for the
nextApproverIds
input indicates that it expects an array, there's no actual parameter that indicates this
In fact, there is an attribute maxOccurs
, that determines if an element is expected more than once. You can use it to to identify if you need to pass an array. This attribute, if declared with the value of 1 would mean it expects only one parameter, anything more than 1 can be treated as an array. You can find more details on this attribute on XML Occurrence Constraints.
The maximum number of times an element may appear is determined by the value of a
maxOccurs
attribute in its declaration
1
Yes, Jayant, that's what I'm looking for. I was not sure what themaxOccurs
attribute was for, but it looks like that might solve my problem! Thanks for the input.
– Emily Davis
14 hours ago
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
If I understand your question, you are looking for a way to identify if an input is array or not.
While the description for the
nextApproverIds
input indicates that it expects an array, there's no actual parameter that indicates this
In fact, there is an attribute maxOccurs
, that determines if an element is expected more than once. You can use it to to identify if you need to pass an array. This attribute, if declared with the value of 1 would mean it expects only one parameter, anything more than 1 can be treated as an array. You can find more details on this attribute on XML Occurrence Constraints.
The maximum number of times an element may appear is determined by the value of a
maxOccurs
attribute in its declaration
If I understand your question, you are looking for a way to identify if an input is array or not.
While the description for the
nextApproverIds
input indicates that it expects an array, there's no actual parameter that indicates this
In fact, there is an attribute maxOccurs
, that determines if an element is expected more than once. You can use it to to identify if you need to pass an array. This attribute, if declared with the value of 1 would mean it expects only one parameter, anything more than 1 can be treated as an array. You can find more details on this attribute on XML Occurrence Constraints.
The maximum number of times an element may appear is determined by the value of a
maxOccurs
attribute in its declaration
answered 16 hours ago
Jayant Das
11.1k2523
11.1k2523
1
Yes, Jayant, that's what I'm looking for. I was not sure what themaxOccurs
attribute was for, but it looks like that might solve my problem! Thanks for the input.
– Emily Davis
14 hours ago
add a comment |
1
Yes, Jayant, that's what I'm looking for. I was not sure what themaxOccurs
attribute was for, but it looks like that might solve my problem! Thanks for the input.
– Emily Davis
14 hours ago
1
1
Yes, Jayant, that's what I'm looking for. I was not sure what the
maxOccurs
attribute was for, but it looks like that might solve my problem! Thanks for the input.– Emily Davis
14 hours ago
Yes, Jayant, that's what I'm looking for. I was not sure what the
maxOccurs
attribute was for, but it looks like that might solve my problem! Thanks for the input.– Emily Davis
14 hours ago
add a comment |
up vote
0
down vote
Not the best way, but you can see the type in the description field.
If description contains keyword "Array" its an array
Thanks Pranay, but I'd really rather not rely on the description, since that's not really a reliable way to know that an input expects an array.
– Emily Davis
16 hours ago
add a comment |
up vote
0
down vote
Not the best way, but you can see the type in the description field.
If description contains keyword "Array" its an array
Thanks Pranay, but I'd really rather not rely on the description, since that's not really a reliable way to know that an input expects an array.
– Emily Davis
16 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
Not the best way, but you can see the type in the description field.
If description contains keyword "Array" its an array
Not the best way, but you can see the type in the description field.
If description contains keyword "Array" its an array
answered 16 hours ago
Pranay Jaiswal
12.5k32251
12.5k32251
Thanks Pranay, but I'd really rather not rely on the description, since that's not really a reliable way to know that an input expects an array.
– Emily Davis
16 hours ago
add a comment |
Thanks Pranay, but I'd really rather not rely on the description, since that's not really a reliable way to know that an input expects an array.
– Emily Davis
16 hours ago
Thanks Pranay, but I'd really rather not rely on the description, since that's not really a reliable way to know that an input expects an array.
– Emily Davis
16 hours ago
Thanks Pranay, but I'd really rather not rely on the description, since that's not really a reliable way to know that an input expects an array.
– Emily Davis
16 hours ago
add a comment |
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f242005%2fstandard-invocable-actions-api-how-to-detect-whether-an-input-expects-an-array%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is your question as how do you identify if an input expects array vs. a single element?
– Jayant Das
16 hours ago