1

I am trying to use an External Service to make an API call with a flow, and have configured a Named Credential, an External Service with swagger schema, and a flow with the resulting apex action, as per this reference article and this trailhead module.

Everything seems to work, but some of the response parameters are not being properly assigned to variables by the flow, instead showing as null.

Here is the relevant piece of the swagger schema:

"responses": {
    "200": {
        "description": "success",
        "schema": {
            "properties": {
                "crm_id": {
                    "description": "MODI customer crm id.",
                    "example": "0031100001VTdOWAA1",
                    "type": "string"
                },
                "status": {
                    "description": "Response status.",
                    "example": "Success",
                    "type": "string"
                },
                "customer_id": {
                    "description": "MODI customer id number.",
                    "example": "3104",
                    "type": "string"
                }
            }
        }
    }
}

In this example, the API responds with a 200 status, and the following json payload (3 strings):

{
  "crm_id":"003f000001DOd6eAAD",
  "status":"success",
  "customer_id":"3314"
}

In the flow debug screen, you can see that one of the parameters has not been assigned, or has been assigned null:

MODI2_CREATECUSTOMER__SERVICE (APEX): modi
Inputs:
createcustomer_input_first_name = {!mat} (mat)
createcustomer_input_last_name = {!vtest} (vtest)
createcustomer_input_crm_id = {!003f000001DOd6eAAD} (003f000001DOd6eAAD)
createcustomer_input_owner = {!ownername} (ownername)
createcustomer_input_type = {!residential} (residential)
createcustomer_input_organization_name = {!orgname} (orgname)
createcustomer_input_email = {!email} (email@email.com)
Outputs:
{!modicrmid} = createcustomer_output_200_crm_id_200 (003f000001DOd6eAAD)
{!customerid} = createcustomer_output_200_customer_id_20 (null)
{!status} = createcustomer_output_200_status_200 (success)`

This made me assume that there was some issue with the schema for the createcustomer_output_200_customer_id_20, but in the developer console apex debug log, you can see that the variables are in fact being assigned, or at least attempting to be assigned, specifically at this line:

[31]|this.createcustomer_output_200_customer_id_200|"3320"|0x60e3f583

here is the rest of the log for reference:

13:32:55.289 (289647519)|EXTERNAL_SERVICE_REQUEST|ExternalServiceSchemaType:OpenApi|ExternalServiceName:modi2|Action:createcustomer|InputParameters:{"input":"{zip=null, owner=ownername, country=null, address=null, address_type=null, create_estimate=null, city=null, last_name=vtest, organization_name=orgname, type=residential, crm_id=003f   <... truncated: 109 characters ...>   
13:32:55.289 (289673655)|EXTERNAL_SERVICE_RESPONSE|ExternalServiceSchemaType:OpenApi|ExternalServiceName:modi2|Action:createcustomer|OutputParameters:{"createcustomer_output_200":"{crm_id=003f000001DOd6eAAD, customer_id=3320, status=success}"}|HttpResponseStatus:200
13:32:55.10 (289727077)|HEAP_ALLOCATE|[4]|Bytes:16
13:32:55.10 (289757299)|METHOD_EXIT|[27]||System.MicroserviceMethods.invokeAction(String, String, Map<String,ANY>)
13:32:55.10 (289768360)|VARIABLE_SCOPE_BEGIN|[27]|outputMap|Map<String,ANY>|true|false
13:32:55.10 (289810421)|VARIABLE_ASSIGNMENT|[27]|outputMap|{"createcustomer_output_200_crm_id_200":"003f000001DOd6eAAD","createcustomer_output_200_customer_id_200":"3320","createcustomer_output_200_status_200":"success"}|0xb1ac153
13:32:55.10 (289819559)|STATEMENT_EXECUTE|[28]
13:32:55.10 (289833937)|HEAP_ALLOCATE|[28]|Bytes:16
13:32:55.10 (289886012)|VARIABLE_SCOPE_BEGIN|[76]|this|modi2_createcustomer__Service.ActionOutput|true|false
13:32:55.10 (289918657)|VARIABLE_ASSIGNMENT|[76]|this|{}|0x60e3f583
13:32:55.10 (289941982)|STATEMENT_EXECUTE|[76]
13:32:55.10 (289943080)|STATEMENT_EXECUTE|[78]
13:32:55.10 (289943768)|STATEMENT_EXECUTE|[80]
13:32:55.10 (289944335)|STATEMENT_EXECUTE|[82]
13:32:55.10 (289949046)|VARIABLE_SCOPE_BEGIN|[28]|output|modi2_createcustomer__Service.ActionOutput|true|false
13:32:55.10 (289962059)|VARIABLE_ASSIGNMENT|[28]|output|{}|0x60e3f583
13:32:55.10 (289966722)|STATEMENT_EXECUTE|[29]
13:32:55.10 (289970618)|HEAP_ALLOCATE|[29]|Bytes:36
13:32:55.10 (290027492)|VARIABLE_ASSIGNMENT|[29]|this.createcustomer_output_200_crm_id_200|"003f000001DOd6eAAD"|0x60e3f583
13:32:55.10 (290033540)|STATEMENT_EXECUTE|[30]
13:32:55.10 (290035172)|HEAP_ALLOCATE|[30]|Bytes:36
13:32:55.10 (290058229)|VARIABLE_ASSIGNMENT|[30]|this.createcustomer_output_200_status_200|"success"|0x60e3f583
13:32:55.10 (290063333)|STATEMENT_EXECUTE|[31]
13:32:55.10 (290065095)|HEAP_ALLOCATE|[31]|Bytes:41
13:32:55.10 (290086500)|VARIABLE_ASSIGNMENT|[31]|this.createcustomer_output_200_customer_id_200|"3320"|0x60e3f583
13:32:55.10 (290091710)|STATEMENT_EXECUTE|[32]
13:32:55.10 (290114240)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
13:32:55.10 (290132327)|HEAP_ALLOCATE|[8]|Bytes:5
13:32:55.10 (290145504)|VARIABLE_ASSIGNMENT|[8]|input|null|
13:32:55.10 (290149782)|STATEMENT_EXECUTE|[35]

I thought it might have something to do with a string field returning numbers, but repeating the same request with the "crm_id" set as an integer and that works fine, so I'm pretty well stumped.

  • At this point I believe this is likely some kind of bug, as I was able to get the flow working properly and returning all values just by changing the key name from customer_id to customerid. I have no idea what that means for the actual naming criteria here, or if it is even directly related to the naming. – mat Jan 21 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.