Converting Task input into boolean

I'm trying to submit a boolean value as an Action input, in the following scenario:

Based on a boolean value in the flow, I request an input (if bool == true) as either 1 or 0, or I default it to 0 if the initial boolean is false.

In the action, I need to submit the 2nd value also as a boolean, but I'm not sure how to convert it.

The formula should be something like

If(originalBool == true AND input == 1, true; else false)

which I tried to write out as

IF(Flow.HasWastelines == true AND Task.Wastelines == "1", true, false)

where Flow.HasWastelines is the value retrieved from Salesforce, and Task.Wastelines is the data input we requested from the caller, or defaulted to 0. (The If() statement shows an error if the 1 is not in quotes.)

I also want to confirm the entry back to the caller, if it was requested -- it looks like ToAudioBool(theBoolean) is how to do that, but the first hurdle is creating the result.

If the input is captured in Task.Wastelines, do I use Set Participant Data to set Flow.Wastelines, or rather Flow.NeedsWastelines using a formula, or do I define it on the fly? Since I want to use it both as an audio prompt and as an Action input, it would be convenient to store it in a Flow variable.

Apparently, there is also/now a schema error in step 10 of the Action, 'Validate output against schema' -

{
"status": 400,
"code": "invalid.schema",
"message": "JSON failed schema validation for the following reasons: instance type (boolean) does not match any allowed primitive type (allowed: ["object"])",
"messageParams": {},
"contextId": "9d6fbd83-f8e7-4fdc-bd37-b8b9ddd13f6d",
"details": [],
"errors": []
}

There are two booleans that I am trying to send to the Action, but particularly as the 2nd one is as yet undefined, I did not include it as a 'required' input in the schema - at least, that was my intent:

{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Patient Inventory submission",
"description": "Schema to submit inventory details to Salesforce",
"type": "object",
"required": [
"ContactId",
"shipDate",
"deliveryDate",
"cartridges",
"saks",
"paks",
"bags",
"warmerLines"
],
"properties": {
"ContactId": {
"type": "string",
"description": "Salesforce Contact.Id"
},
"isPureFlow": {
"type": "boolean",
"description": "PureFlow Patient?",
"default": false
},
"shipDate": {
"type": "string",
"description": "Inventory Ship Date"
},
"deliveryDate": {
"type": "string",
"description": "Expected Delivery Date"
},
"cartridges": {
"type": "integer",
"description": "Cartridge Qty"
},
"saks": {
"type": "integer",
"description": "SAK Qty"
},
"paks": {
"type": "integer",
"description": "PAK Qty"
},
"bags": {
"type": "integer",
"description": "Bag Qty"
},
"warmerLines": {
"type": "integer",
"description": "Warmer Bag Qty"
},
"needsWastelines": {
"type": "boolean",
"description": "Needs Wastelines?",
"default": false
}
},
"additionalProperties": true
}

I am expecting a boolean result, but it does not appear that I am hitting Salesforce yet with this Action; is there any way to determine which part of the schema is failing?

My response contract follows, but it seems as though the error is happening before that:

{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Inventory submission result",
"description": "response",
"type": "object",
"properties": {
"submissionSuccessful": {
"type": [
"boolean",
"null"
]
}
},
"additionalProperties": true
}

Okay, that last Action error may be due to the fact that the web service is taking a while to process, and the Action is timing out before it's complete(?). I still have the boolean question to resolve, though, as I will need to know what the caller entered for a response. Right now I'm just passing false for that NeedsWarmerlines parameter.

I would suggest resolving all of the schema issues with the action in the UI test mode prior to working out kinks in the Architect flow.

I am expecting a boolean result, but it does not appear that I am hitting Salesforce yet with this Action; is there any way to determine which part of the schema is failing?

Since you are getting to step 10 the action has already contacted Salesforce and got a 200/success response.

My guess of what the schema error is saying is that your action is returning something like this:

"submissionSuccessful" : true

which is a straight Boolean, instead of this:

{
"submissionSuccessful" : true
}

which is a Boolean wrapped in an object.

Correct - once I wrapped the boolean (and a string message indicating the state of the transaction on the Salesforce side) in my Apex web service, the Action issue was addressed.

Getting back to the caller's input, however -- if the caller responds to a prompt with a '0' or '1', how do I convert that to a boolean that I can use in the flow? Is it a Set Participant Data method, and do I convert it to a different Task.variableName?

It looks like the "Data" -> "Update Data" tool is what you want to set the boolean variable and make it available to the task or flow.

Perfect -- thanks again Jason!

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.