Setting dynamic metadata in gprc Resource

Hi,

In the configuration of the resource, I want to log which user and process called the service

However when we check the logs we just get the string "{{ 'retool:' + current_user.email }}" returned without picking up the dynamic information

The workaround would be to set this in every page and instance where the services are called instead of the resource, but that's painful with our setup.

Thanks in advance,

David

Hey David! Could you try without the double curlies in your resource set up page?

Hi Victoria,

It just sends the same text without the curlies.

FYI We just migrated to 3.0.1 self hosted

Hi @DavidM Can you try upgrading to 3.4+

Hi @Tess,

We just upgraded to 3.8.1

I set the grpc resource with the key and it recognised the dynamic values:

But when I check the logs on the service it's not being translated:

Let me know if there's anything else I should try?

Thanks,

David

Hi David,

Thanks for the screenshot! Sorry you're still running into issues here :disappointed: I believe it's happening because there is additional JS transformation on the current_user object. I'm guessing if you only pass {{current_user.email}}, it'll work :crossed_fingers: That said, I realize that doesn't solve your use case. I can reach out to our team about supporting JS here

@DavidM Can you try refactoring the example you previously shared to the below syntax? Our internal engineers reviewed this issue & we want to confirm that this is now working:

Hi Tess
It's much better now though the logic to check if it's in edit mode only works when set in the app, but not the resource

I used the following for both tests:

retool({{retoolContext.appName}}):{{current_user.email}} {{retoolContext.inEditorMode ? ' (edit)' : ''}}

Hi @DavidM Glad to hear!

Hmm, its a bit strange that appName works from the resource page, but inEditorMode doesn't. Do you want it to say "" when triggered from the resource page? Does it help if you add some logic to check if retoolContext is defined? Maybe something like retool({{retoolContext?.appName}}):{{current_user.email}} {{(retoolContext?.inEditorMode) ? ' (edit)' : ''}}