Skip to main content
Question

Was a record created through a form, grid edit, or API_AddRecord?

  • October 25, 2018
  • 0 replies
  • 66 views

I'd like to have a field that shows the following three text options: Form, Grid, API

Is there code that can detect how the record was created and paste one of these three results into my desired field? I'm trying to track users in our apps and this would help immensely with oversight for certain company initiatives.

Thanks for any help!!
This topic has been closed for replies.

  • Registered
  • October 25, 2018
Create a table called source. In that table make the records have a numeric value tied to each source. 1 = API 2 = form and 3 = grid. Place the related lookup field inside of your record form where you are wanting to track how these came in. Now when they do the api edit record call add their field ID to the call and the number is value 1 to be sent over. Same with the form. And with grid edit just make an action or automation that basically states if it comes in without a source then write grid edit in source, since you only have 3 options and the other 2 are taken care of.

There is probably a simpler way, but this way would be 100% automated.

  • Author
  • Registered
  • October 25, 2018
Thanks a lot John, I'll try this

  • Registered
  • October 25, 2018
You could do this with a Service Worker but I think there would be more than three cases to decode. Basically the Service Worker would monitor network traffic and if it sees for example an ?a=er it would modify the network request to include an extra field indicating a form was used. Likewise, if ?act=API_* was seen it would modify the network request to include the extra field indicating an API was used. Similar arrangement for Grid Edit.

You would need to cover both GET and POST requests slightly differently and to be comprehensive you might want to record with imports separately.

The main challenge would be to discover and cover all the edge cases.

  • Author
  • Registered
  • October 25, 2018
Thank you too Dan, would you mind linking me the best sources to find more information on Service Workers and how to get started using them? I've read about capabilities you've mentioned in other posts and I have a programmer that is interested in testing them out in our apps.