Application Studio - Use Button to lookup and fill OrderHed Comments with User Session information

I’m wanting to grab user session data via button click → rest-erp control then fill an OrderHed.XX field.

image

image

image

image

Then on the row-update control use the following…
image

The result comes into the EP Binding field as (undefined).

What am I missing. I can see that the res-erp request is successful and returns the REST response in Developer Tools. But the row-update doesn’t successfully parse the data.

If you are just wanting the current user id you can use the session to get it. Put this in as the value you are setting your epibinding to in row-update

%session.context.user%

This post shows a nice screenshot of what is available in session context

%session.context… does work but I’d like to get the current user email. I think that field is also in session.context but is empty.

There would be some other cases in the future where I’ll want to make requests like this so I’m hoping to get this to work.

I do see now that %session.context.userEmail% does not work.

You will want to create a view to hold the returned data from that call, however, I tried every iteration I know of to handle the response parameters and never parses the rest response correctly.

As a workaround you could call UserFile.GetByID and passing in the parameter value %session.context.user% and parsing the result to a custom dataview

image

Tried this approach and I can see the response results come back successfully from Developer Tools. However the binding returns {UserInfo.EMailAddress}. Seems like I’m really close though. What am I missing? Did I spell something wrong maybe?

image

image

Did you add UserInfo as a dataview?

I didn’t have the view. I’ve now included it. However now the binding returns “undefined”. Is there something else I have to set up on the view? Do I need to verify that it’s being filled (and how would you do that)?

image

Make sure your UserInfo view is being populated, this post outlines debugging in Kinetic

Success… thanks so much for your help!

I noticed in Developer Tools that the GetByID request was no longer happening. So I removed the response parameter and added it in again. From what I can see there are no differences but it now works. I read in another of hmwillet’s posts where she mentions that you can do this without a dataview and just use actionResult, but I couldn’t get that to work. I must be missing or misunderstanding some detail.

I always use views if doing a rest call like this, I could never get it to work without parsing results to views

Okay–you piqued my curiosity with the Ice.BO.KineticErpSvc call and after much trial and error, I got it figured out…
The issue with this particular call is it returns an object instead of a collection. The typical rest-erp widget likes to iterate through something and there was nothing to iterate through.

I was able to get it to work using the “Generic” rest widget.

Do with that what you will.
I was just annoyed the call wasn’t working as the others do and was determined to figure it out.

3 Likes

This is great information Hannah. Thanks for adding your input.

I’m just getting started with these kinds of advanced customizations with Application Studio and while I can see this solution works, I wonder if it makes more sense to use BPM for things like this (and if it’s possible). I’m also green to BPM but from what I’ve seen I wonder if it’s the better and more user friendly approach. One reason is that it seems like there’s more of a self-documenting nature to BPM. With the Application Studio approach you have to manually document (or remember) these advanced customizations, otherwise I don’t see a way to find all customizations related to a particular app. This could be extremely frustrating for someone trying to modify or troubleshoot a customization.

Another thing I noticed is the very loose reference to events. For example I can create the onclick event for a button and design the logic, but if I change the name of the button then all references are lost and it’s very difficult, if not impossible, to find the previous onclick event name, let alone to try to point the button to that event again, which means rewriting all the logic.

I’d be interested to hear any guidance you or other experts might have on this if you have time to respond.

Thank you.

Always use server-side tools where possible.
You generally want to minimize the amount each client has to process and render to keep their application snappy. I’m sure there’s also some security aspect to it, but that’s not my wheelhouse.

Nature of the beast with UI customizations (AKA App Studio).
A different approach would be to leave the ID of the button as it is, give it an EpBinding, then change the event to EpBinding/OnClick/WhateverYourBindingIs. That would prevent a bit of that issue unless you’re changing the binding and I would suggest just… not doing that, lol. You can also start using Row Rules to affect said button if it has a binding like enabling or visibility or whatever.

You’ll get this no matter where you customize something.
In BPMs/Functions you have to should comment your code, give it appropriate descriptions, group names, etc. It’s no different in App Studio. Name your events something meaningful. Instead of erp-button-4a16a_onClick, rename it to ce_btnEmail_onClick (ce_ is my prefix for custom event). You can also add comments to every widget and every event in App Studio.
At Stephen Gould, we have our own Discourse site where we log everything about a customization we work on.
Here’s an example of one I did this morning:

Depends. It’s a lot more documented and there’s a long history of posts here for help vs App Studio which is notoriously bad for documentation and you’re stuck with posts from me on how to do things. :sweat_smile:

Going back to me custom prefix. I name all dataviews cdv_, all rules cr_, events ce_. It makes it quite searchable in your layer. Strictly speaking, you could do the same with controls. You would then run Dev Tools on the layer and press some hot key (don’t remember off the top of my head) which lists all controls.

pink love GIF by Denyse

Thanks again for taking the time to answer my questions. Your recommendations all make sense within the framework of Kinetic customizations and development and will be helpful as I try to keep things as clean as possible. I’ve worked with ERP systems that track customizations in an organized way so that it’s much easier to find and troubleshoot code, so I was hoping/assuming Kinetic would be similar. I’m tempted to add fields directly to the App to track notes/details related to customizations directly within that App.

Seems appropriate to post @klincecum’s favorite GIF here:

first time GIF

Welcome to Kinetic. :slight_smile:

I also feel a bit like this when answering Kinetic questions:

https://media.giphy.com/media/SLbZ0D6YoO7io/giphy-downsized-large.gif

Or Wonsil’s DevOps Groundhog Day…

bill murray GIF

1 Like