# Using a web request - is it possible to map response directly as references to existing Enums or Object Classes?

**URL:** <https://community.appfarm.io/t/using-a-web-request-is-it-possible-to-map-response-directly-as-references-to-existing-enums-or-object-classes/40>\
**Category:** Ask the community\
**Tags:** service, web-request, integration\
**Created:** [December 2, 2022, 9:26am UTC](https://community.appfarm.io/t/using-a-web-request-is-it-possible-to-map-response-directly-as-references-to-existing-enums-or-object-classes/40 "2022-12-02T09:26:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fridtjof](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/fridtjof/32/262_2.png) [@Fridtjof](https://community.appfarm.io/u/Fridtjof)\
**Post date:** [December 2, 2022, 9:26am UTC](https://community.appfarm.io/t/using-a-web-request-is-it-possible-to-map-response-directly-as-references-to-existing-enums-or-object-classes/40/1 "2022-12-02T09:26:19Z")

</div>

I’m working on mapping a large list of properties from an API call to an existing object in Appfarm. The existing object has some properties which are enums/objects. Is there a way of directly linking a string in the API response to an existing enum or object? My current workaround is to make runtime properties of all these and then recalculate in a separate action step. It would be nice to be able to make a javascript function on a property in the mapping - to set the correct property directly in the property mapping.

---

<div class="post-metadata">

**Author:** ![kristian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/kristian/32/58_2.png) [@kristian](https://community.appfarm.io/u/kristian)\
**Post date:** [December 2, 2022, 9:28am UTC](https://community.appfarm.io/t/using-a-web-request-is-it-possible-to-map-response-directly-as-references-to-existing-enums-or-object-classes/40/2 "2022-12-02T09:28:50Z")

</div>

Regarding the enum: Let’s say you receive a fixed set of order statuses “open”, “in\_progress” or “finished” as values in the JSON when receiving orders from an external system:  
If you create this Enum in the Global Data Model as a “String” type and add Open, In Progress, and Finished entries with values “open”, “in\_progress” and “finished” as entries: You may map the response directly.

Using the Result Parser, the function parameter rawResponseData contains the raw respons. If thw following is returned from the web request:

```auto
{ 
    "CompanyName": "Appfarm",
    "OrgNo": "123456789",
    "ResponsiblePersonEmployeeNo": "999999"
}

```

…then rawReponseData is an Object with 3 properties.

If I want to tweak the value of Appfarm before I do result mapping, then the result parser may be:

```auto
rawResponsData.CompanyName = "Appfarm AS"
return rawResponseData

```

→ The value of CompanyName in the result mapping is then “Appfarm AS”

Using this concept, you may e.g. add a new property to rawResponseData, before returning it. The result parser will then be:

```auto
let respPerson = persons.filter(x => x.employeeNo == rawResponseData.ResponsiblePersonEmployeeNo)
rawResponsData.ResponsiblePersonID = respPerson[0]._id
return rawResponseData

```

In the above example, I have added the persons datasource as a function parameter, containing all possible employees. When rawResponseData is returned, it now contains a property ResponsiblePersonID which can be used in the Result Mapping directly into the reference to the responsible person
