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!










share|improve this question
























  • Is your question as how do you identify if an input expects array vs. a single element?
    – Jayant Das
    16 hours ago















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!










share|improve this question
























  • Is your question as how do you identify if an input expects array vs. a single element?
    – Jayant Das
    16 hours ago













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!










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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










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







share|improve this answer

















  • 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


















up vote
0
down vote













Not the best way, but you can see the type in the description field.



enter image description here



If description contains keyword "Array" its an array






share|improve this answer





















  • 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











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "459"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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







share|improve this answer

















  • 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















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







share|improve this answer

















  • 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













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







share|improve this answer












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








share|improve this answer












share|improve this answer



share|improve this answer










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 the maxOccurs attribute was for, but it looks like that might solve my problem! Thanks for the input.
    – Emily Davis
    14 hours ago














  • 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








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












up vote
0
down vote













Not the best way, but you can see the type in the description field.



enter image description here



If description contains keyword "Array" its an array






share|improve this answer





















  • 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















up vote
0
down vote













Not the best way, but you can see the type in the description field.



enter image description here



If description contains keyword "Array" its an array






share|improve this answer





















  • 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













up vote
0
down vote










up vote
0
down vote









Not the best way, but you can see the type in the description field.



enter image description here



If description contains keyword "Array" its an array






share|improve this answer












Not the best way, but you can see the type in the description field.



enter image description here



If description contains keyword "Array" its an array







share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei