Legacy Dev Forum Posts

 View Only

Sign Up

Get customField from Organization in Actions

  • 1.  Get customField from Organization in Actions

    Posted 06-05-2025 18:41

    Philip_Hagenfeldt | 2020-09-04 10:40:22 UTC | #1

    Hi,

    I'm trying to get a value from customField in Organization in a PureCloud Data Action, but can't seem to get it to work.

    Input contract:

    { "type": "object", "properties": { "query": { "type": "string" } }, "additionalProperties": true }

    Output contract:

    { "type": "object", "properties": { "id": { "type": "string" }, "optOut": { "type": "string" } }, "additionalProperties": true }

    Request URL: /api/v2/externalcontacts/organizations?q=${input.query}

    Response: { "translationMap": { "id": "$.entities[0].id", "optOut": "$.entities[0].customFields.optoutofsurveyscheckbox" }, "translationMapDefaults": {}, "successTemplate": "{\"id\": ${id}}, {\"optOut\": ${optOut}}" }

    I get the id but the field optOut is empty:

    The response in raw is:

    { "entities": [ { "id": "censored", "name": "censored", "tags": [], "websites": [], "tickers": [], "modifyDate": "2020-09-04T07:47:55Z", "createDate": "2020-08-27T10:31:52Z", "schema": { "id": "censored", "version": 2, "selfUri": "censored" }, "customFields": { "companyidentifier": "censored", "iscustomercheckbox": true, "issuppliercheckbox": false, "optoutofsurveyscheckbox": true, "organisationalnumber_identifier": "censored" }, "selfUri": "censored" } ], "pageSize": 25, "pageNumber": 1, "total": 1, "firstUri": "censored", "selfUri": "censored", "lastUri": "/censored", "pageCount": 1 }

    Can someone see what's wrong and maybe push me in the right direction?


    Jerome.Saint-Marc | 2020-09-04 11:51:22 UTC | #2

    Hello,

    I think you have 2 errors in your Data Action configuration.

    The first thing is that optoutofsurveyscheckbox value is a boolean, not a string. So, in your Output Contract, update the type for the optOut property -> from string to boolean.

    I see a second error in your Response Configuration - error in the successTemplate format.

    { "translationMap": { "id": "$.entities[0].id", "optOut": "$.entities[0].customFields.optoutofsurveyscheckbox" }, "translationMapDefaults": {}, "successTemplate": "{\"id\": ${id}, \"optOut\": ${optOut}}" }

    Regards,


    Philip_Hagenfeldt | 2020-09-04 12:27:58 UTC | #3

    Ah, I thought it word return the string True, even though it is a boolean. Your changes worked, thank you very much!


    system | 2020-10-05 12:27:59 UTC | #4

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


    This post was migrated from the old Developer Forum.

    ref: 8746