We’ve developed some resources to help you work effectively from home during COVID-19 Click to learn more

Fetching field based on values from another table via REST

Hi,

We need to fetch a specific field used in Service via REST, but it has proven difficult as it is not just a value from a single table.

Namely, our Service has a field called "Brukernavn" which we use extremely often in an abundance of different ways.

 

The logic behind this field is:

ticket.cust_id.(user_candidate->person_id).secret_key

 

Meaning we cannot just use the "Ticket" endpoint in REST, but I am guessing we need some way to query the "USER_CANDIDATE" table as well.

 

How can we proceed with this?

Any help is appreciated.

Thanks!

RE: Fetching field based on values from another table via REST

It is also worth mentioning that we use the same field on "Person":

person.(user_candidate->person_id).secret_key

Av: Markus Moripen 16. sep 2019

RE: Fetching field based on values from another table via REST

Hi Markus,

I don't understand the context, but generally you want to include a criteria/restriction to limit the results. Regardless, here is an example based on a person_id criteria.

/api/v1/Archive/dynamic?$select=person.person_id,person.firstname,person.lastname,person.(user_candidate->person_id).secret_key&$filter=person.person_id = 20

Hope this helps!

Av: Tony Yates 17. sep 2019

RE: Fetching field based on values from a secondary table via REST

Hi Tony,

Thanks for the reply! No problem, I don't think I explained it very good either.

 

A bit of context:

The field I mentioned ("Brukernavn") is, for example, used on the ticketInfo-section on a ticket in Service.

 

The same goes for the info-section on a person in Service:

 

 

We are looking for a way to fetch specific persons/users for our customers by the use of this field.

Ex: If I was to query "aa90" (my username), I would get a response with person_id, name etc. for myself.

Av: Markus Moripen 17. sep 2019

RE: Fetching field based on values from another table via REST

Hi Markus,

Here is an example that gets person details using the person secret_key (Jane.Doe here, yours would be aa90) as the criteria:

/api/v1/Archive/dynamic?$select=person.person_id,person.firstname,person.lastname&$filter=person.(user_candidate->person_id).secret_key is Jane.Doe

Hope this helps!

Av: Tony Yates 18. sep 2019

RE: Fetching field based on values from another table via REST

Hi Tony,

Both of your examples worked perfectly, thanks!

I guess we just have to do it this way with OData instead.

 

Side-note; Are you planning on adding "user_candidate" as an entity for REST at some point?

This would help us quite a lot.

 

Again, thank you!

Av: Markus Moripen 18. sep 2019

RE: Fetching field based on values from another table via REST

Hi Markus,

No, I do not believe that will ever happen. 

Best regards!

Av: Tony Yates 18. sep 2019