VolkovLabs / business-forms

The Business Forms panel is a conceptually new plugin for Grafana. It is the first plugin that allows inserting and updating application data, as well as modifying configuration directly from your Grafana dashboard.
https://docs.volkovlabs.io
Apache License 2.0
86 stars 10 forks source link

[Question] ReplaceVariables not working? #533

Closed henjoe closed 3 weeks ago

henjoe commented 3 weeks ago

I want to automatically fill in my "Text Input" to be the current user in Grafana.

On my element Value changed event I have the ff code:

context.panel.elements.forEach(ele => {
  if (ele.id === 'name') {
    let currentUser = context.grafana.replaceVariables("${__user.login}");
    console.log('CurrentUser: ' + currentUser)
    ele.value = currentUser;
  }
})

but seems like the context.grafana.replaceVariables("${__user.login}") is not working. I received this error: image

What could be the temporary solutions for this kind of use case? Is there a way I can include the current login user in payload update request?

Version: 3.8.0 Grafana: V9.2.2 OS: Windows

Thank you.

henjoe commented 3 weeks ago

Changing the code from here:

 if (ele.id === 'name') {
    ele.value = "${__user.email}";
  }

Works fine for my Grafana version v9.2.20 and BusinessForm 3.8.0

mikhail-vl commented 3 weeks ago

@henjoe That's correct. Business Forms replaces dashboard variables automatically.