Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good afternoon, I would like to know if you can get the macro messages and display them in a text field. For example, I would like to show how many records have been updated for a particular company. I currently have a macro script that does an update. But in Qlik Server I can not use msgbox. Is there any way to show these messages to the user? Would you like to upload a loading image? I hope you can help me. Thank you for now.
If you need to show the users any results from the script processing, you can do a few things:
1. You can use TRACE to add messages to the Script Execution Progress text (and the log).
2. You can store variables with all the necessary information and then show the variables on the screen with the relevant explanation.
3. If variables are not enough, you could create aggregated tables and show them on the screen. For example a table with the fields Company and [Number of updated records].
cheers,
Oleg Troyansky
Upgrade Your Qlik Skills at the Masters Summit for Qlik - coming soon to Munich, Germany!
Thanks for the feedback, what I'm trying to do is, I have this macro that does update in a database table. For the desktop after after the execution I get a msgbox on the screen with the message that I inform, but this does not work on the qview server. Would there be any way to display a message to the user on the qlik server? Type show a update message completed successfully, and show how many records have been updated. I'm also having trouble creating an if, with the Select variable, in it I can option S or N. Thanks for now. Below the macro I'm using.
Function GetAgentConnection
Dim oConection
Dim SLXServerName
Dim SLXDataBaseName
Dim SLXUserPassword
Dim SLXUserName
Dim sConnectionString
sConnectionString = "Provider=MSDASQL.1;Persist Security Info=True;User ID=root;Data Source=GHAN_BI;Extended Properties=DSN=GHAN_BI;UID=root;Initial Catalog=ghan_bi] (XPassword is JHLDSJVMYbbMCbEHRRMGDAC)"
Set oConection = CreateObject ("ADODB.Connection")
oConection.ConnectionString = sConnectionString
oConection.Open
Set GetAgentConnection = oConection
End Function
'Salva na tabela Vendas Diario
Sub QV2SQL
SET Conexao = GetAgentConnection()
dim uSQL
dim RegAfectados
dim importe
RegAfectados = 0
set val1=ActiveDocument.Fields("DATAFORMATOBD").GetSelectedValues
set val2=ActiveDocument.Fields("SELECIONA").GetSelectedValues
for i=0 to val1.Count-1
Conexao.Execute "UPDATE bi_agencia_stur_vendas_diario SET conferido='"+val2.Item(i).Text+"' WHERE data_emissao = '"+val1.Item(i).Text+"'"
next
Msgbox("Registros atualizados com sucesso!")
End Sub
'Salva na tabela Lançamento, utilizada para o fechamento do BI.
Sub QV2SQL2
SET Conexao = GetAgentConnection()
dim uSQL
dim RegAfectados
dim importe
RegAfectados = 0
set val1=ActiveDocument.Fields("CalendarioCompleto").GetSelectedValues
set val2=ActiveDocument.Fields("Seleciona").GetSelectedValues
set val3=ActiveDocument.Fields("ID_EMPRESA").GetSelectedValues
for i=0 to val1.Count-1
Conexao.Execute "UPDATE bi_nivel_4_lancamento SET fechado='"+val2.Item(i).Text+"' WHERE data_emissao_dre = '"+val1.Item(i).Text+"' and data_cadastro = '"+val3.Item(i).Text+"'"
next
Msgbox("Registros atualizados com sucesso!")
End Sub
I'd go for modifying a value of a variable and have the variable displayed on the screen. I'm not sure what else would work on a QlikView server.
I'd also recommend to look at the extension called Kildins that allows writing data back to SQL server, and it's very robust and doesn't require tinkering with Macros: